How does this js code output 10?? | Sololearn: Learn to code for FREE!

+1

How does this js code output 10??

alert(++[[]][+[]]+[+[]]);

11/29/2021 8:00:43 PM

MATOVU CALEB

2 Answers

New Answer

+6

I don't know how it works but is called jsfuck: https://en.m.wikipedia.org/wiki/JSFuck http://www.jsfuck.com/

+2

[] 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