If you define an object using const, the object contents can be amended.Ī constant can’t have the same name as a function or variable in the same scope. However, the value held by a constant is not immutable. You can’t change the value of a constant by re-assignment, and it can’t be re-declared. Variables declared in this way are read-only constants. This is another way to declare variables - like let, variables const has block scope. Variables defined with var and const are function scoped, whereas variables defined with let are block-scoped.īlock scoping basically means that the variable scope is limited by the enclosing )) // returns Array const: Declare a block-scoped read-only constant.let: Declare a block-scoped local variable, optionally assigning a value.
0 Comments
Leave a Reply. |