Declare a Read-Only Variable with the const Keyword

Опубликовано: 06 Май 2026
на канале: HighTech6839v
69
1

JavaScript Const - The const keyword was introduced in ES6. Variables defined with const cannot be Redeclared. Variables defined with const cannot be Reassigned. Variables defined with const have Block Scope.

In JavaScript, `const` means that the identifier can't be reassigned. (Not to be confused with immutable values. Unlike true immutable datatypes such as those produced by Immutable. js and Mori, a `const` object can have properties mutated.)

Why should we use const JavaScript? Summary. As a general rule, you should always declare variables with const, if you realize that the value of the variable needs to change, go back and change it to let. Use let when you know that the value of a variable will change. Use const for every other variable.

Read-only variable - The readonly keyword can be used to define a variable or an object as readable only. This means that the variable or object can be assigned a value at the class scope or in a constructor only. You cannot change the value or reassign a value to a readonly variable or object in any other method except the constructor.

What is the let in JavaScript? let allows you to declare variables that are limited to the scope of a block statement, or expression on which it is used, unlike the var keyword, which declares a variable globally, or locally to an entire function regardless of block scope.

What is the difference between let and const JavaScript? `const` is a signal that the identifier won't be reassigned. `let` is a signal that the variable may be reassigned, such as a counter in a loop, or a value swap in an algorithm. It also signals that the variable will be used only in the block it's defined in, which is not always the entire containing function.

How to uppercase in JavaScript? The toUpperCase() method converts a string to uppercase letters. The toUpperCase() method does not change the original string.

Camel case (sometimes stylized as camelCase or CamelCase, also known as camel caps or more formally as medial capitals) is the practice of writing phrases without spaces or punctuation. The format indicates the separation of words with a single capitalized letter, and the first word starting with either case.

For more information about camelCase click on the link down below:
https://en.wikipedia.org/wiki/Camel_c....

If you console.log(fact); you'll only see the text - is awesome!
If you console.log(FCC); you'll only see the text - freeCodeCamp.
console.log(FCC, fact); will give you the text - freeCodeCamp is awesome!