Difference between var, let and const
In JavaScript, variables are assigned using three main keywords/ways which are:-
var
let
const....
For further actions, you may consider blocking this person and/or reporting abuse
Const can be updated if it's an object or array. This is fine, for example:
So
constis kinda-sorta-const, depending where you learned the word "constant". You can't redeclare it or make it point at anything else, but you can modify it if it's a container for other things.Const gives you a constant memory reference. You can't reassign the memory reference, but any properties can be [re]assigned. The constant value assumption is only for primitive types.
To freeze objects: developer.mozilla.org/en-US/docs/W...
It's not a reference to specific memory. The thing pointed to by a const variable can and often will move locations in memory (for example if you keep pushing onto an array, the engine will eventually have to allocate a new, bigger block of memory for it). It's just a constant reference to a specific
value.Thanks for the clarification.
I'll check on this. Thanks for the feedback
Thanks for this information, I will learn it and update it
The computer science definition of constant existed for forty years or more before JavaScript decided to use the same term for something different than most computer languages and in mathematics.