DEV Community

Discussion on: Var vs Let vs Const in Javascript

Collapse
 
pentacular profile image
pentacular

Similarly arrays declared with const keyword [...]

The insight here should be that you do not declare arrays with the const keyword.

You declare variables with the const keyword.

The value bound to the variable is independent of this.

Consider the following example.

const a = [1, 2, 3];
let b = a;

If this were declaring the array, then the array would be both const and non-const at the same time, which would be problematic.

Collapse
 
sruthiragupathy profile image
sruthiragupathy • Edited

Alright, this makes sense! Thank you for letting me know. But here 'a' remains unchanged , though u can change 'b' right , hence preserving the const array.

Collapse
 
pentacular profile image
pentacular • Edited

The array is not affected by const in either case.

So it's not reasonable to talk about the "const array".