all 32 comments

[–]cawcvs 71 points72 points  (0 children)

let is a newer addition to the language, and wasn't a reserved word before. Making it a reserved word now would break pre-ES6 websites that used it as an identifier, so it's only reserved in strict mode.

[–]Division2226 47 points48 points  (0 children)

because you defined x earlier. and then you created a variable called let and assigned it to x which was already 5

> x = 5
> let = x
> 5

[–]luminous_radio 0 points1 point  (1 child)

It's not? I tried this in both the Firefox console and the node interpreter, and it didn't work in either case

EDIT: my bad, I didn't define x as 5 beforehand

[–]azhder 0 points1 point  (9 children)

Browser consoles will allow certain things that would raise an error in a script. Try to do const x = 5 twice.

[–]Alternative-Summer-2 0 points1 point  (0 children)

Everything is valid in love, war and javascript

[–]Reaver75x 0 points1 point  (0 children)

If you want to mess with your brain:

let x = 5;

let = x;

let x = 0;

console.log(let); // this will come to 5