Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 2
How does this js code output 10??
alert(++[[]][+[]]+[+[]]);
2 Answers
+ 6
I don't know how it works but is called jsfuck:
https://en.m.wikipedia.org/wiki/JSFuck
http://www.jsfuck.com/
+ 3
[] is an empty array, if you put + in front of it, the compiler converts it to Integer:
+[] => 0
++[[]][+[]] respectively, this is the first value of the empty array to which 1 was added.
As a result, '1' + '0' => 10