You miss semicolon
var b = {}; [b] = [3] console.log("b->",b)
this would work as expected. It is easy to discover, if you use let:
let
let b = {} [b] = [3] console.log("b->",b) // Uncaught ReferenceError: can't access lexical declaration 'b' before initialization
Original code:
var b = {} [b] = [3]
which is the same as
var b = {}[b] = [3]
var b = [3]
Thanks a lot. It seemed absurd to me. All makes sense now!
Wow, nice spot, and worrying for me because I never use semicolons anymore. But I also almost never use var. I guess I've been luck so far.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You miss semicolon
this would work as expected. It is easy to discover, if you use
let
:Original code:
which is the same as
which is the same as
Thanks a lot. It seemed absurd to me. All makes sense now!
Wow, nice spot, and worrying for me because I never use semicolons anymore. But I also almost never use var. I guess I've been luck so far.