Constants are read-only, defined with the const keyword.
Ex: const price = 100;
constant should be initialized to a value and it cannot be re-declared.
You cannot declare a const with same name as a function name and declaring it in the same scope.
For Example :
function a() {};
const a = 15; // This will cause an error.
function a(){
const a =15; // This will also cause an error.
//statements
}
Properties of the object which are assigned are not protected and they are defined as:
const myObject= {'key': 'value'};
myObject.key = "Name";
myObject.value = "blog-spot";
Ex: const price = 100;
constant should be initialized to a value and it cannot be re-declared.
You cannot declare a const with same name as a function name and declaring it in the same scope.
For Example :
function a() {};
const a = 15; // This will cause an error.
function a(){
const a =15; // This will also cause an error.
//statements
}
Properties of the object which are assigned are not protected and they are defined as:
const myObject= {'key': 'value'};
myObject.key = "Name";
myObject.value = "blog-spot";
No comments:
Post a Comment