What is const in Javascript
By FoxLearn 12/18/2024 4:43:26 AM 18
`const` is a JavaScript keyword used to declare a variable whose value cannot be reassigned after initialization.
It stands for "constant," meaning the value set cannot be changed later in the code.
const pi = 3.14; console.log(pi); // Outputs: 3.14
This line would cause an error because a constant variable cannot be reassigned.
Attempting to do so results in a TypeError: Assignment to constant variable.
Categories
Popular Posts
11 Things You Didn't Know About Cloudflare
12/19/2024