+ 5
What is the difference between var and const in JavaScript
var and const is the same.
2 Respostas
+ 5
Const is used to declare a constant => you can't change it after assigning a value. You can read more here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const and here https://dev.to/sarah_chima/var-let-and-const--whats-the-difference-69e.
- 1
var is a function scope ,but const is block scope
like a
if(...){
const x=0;
}
console.log(x);
out if scope x is not visible