This is valid and returns the number 1 in JavaScript:
++[[]][0]
Why doesn't it reporting an error like ++[]
?
Isn't it the same as ++[]
?
NOTE: This is a bit different than: Why does ++[[]][+[]]+[+[]] return the string “10”.
What I mean is that why doesn't ++[[]][0]
report an error? Is [[]][0]
a variable? If not, why doesn't it report the error like:
++[] // returns Invalid left-hand side expression in prefix operation.