If you have any query feel free to chat us!
Happy Coding! Happy Learning!
In JavaScript, const is a keyword that is used to declare a variable whose value cannot be reassigned. Once a variable is declared with const, its value remains constant throughout the program. If you try to reassign the value of a const variable, you will get a TypeError.
For example, consider the following code:
arduinoCopy code
const x = 10;
x = 20; // TypeError: Assignment to constant variable.
Here, the value of x is declared as 10 using const. When we try to reassign x to 20, we get a TypeError since x is a const variable and its value cannot be changed.
It is important to note that while const prevents reassignment of the variable itself, it does not prevent mutation of the object or array that the variable is referring to. For example:
arduinoCopy code
const arr = [1, 2, 3];
arr.push(4); // OK
const obj = { foo: "bar" };
obj.baz = "qux"; // OK
Here, we declared a const variable arr as an array, and we added a new element to the array using push(). Similarly, we declared a const variable obj as an object and added a new property to the object using dot notation.
Complete 100% to unlock your certificate

When will I get my course?

Now, Your query was resolved.
Quick answers to common questions about our courses, quizzes, and learning platform
Didn't find what you're looking for?
help_center Contact Support
I am not able to access videos from second class and further. I have already completed first class