JavaScript expression

Can someone help me with this javascript expression?

+[[+!![]]+[+![]]+[+!![]]+[-~!![]+-~!![]-~!![]]+[-~!![]]+[+![]]+[+!![]]+[-~!![]+-~!![]]]

A friend sent it to me and asked to copy and paste it into the browser console.

This is the result:

10162014

If anyone can explain this to me, or at least point me to the correct links, please. Thank!

+4
source share
3 answers

First, execute the code: !![]which returns true (!! to convert to boolean), and now +converts to a number, therefore +!![]returns 1.

![]converts to false, therefore +![]returns 0.

~[]returns -1as well ~![]as returns -1.

~!![]returns -2.

-~!![] 2 -~![] 1.

, 10162014.

, , ~,!, + -

+3

![] = false; # , - ! [] = true; # , , true

+!![] = 1;, +true = 1; +![] = 1;, +true = 0, + JS ref

, , boolean to integer .

+2

[+!![]]+[+![]]+[+!![]]: [] - , . ![], , , !![] . +true , 1. +![] 0 false.

[-~!![]+-~!![]-~!![]]: ~- operator with two additions; ~1- -2. Thus, it is evaluated as -(-2)+-(-2)+-(-2), which is equal 6.

The remaining additions are similar.

array + arrayconverts arrays to strings; this way [1]+[0]+[1]+[6]...will give a string"1016..."

Plus, at startup, converts it to a number.

+1
source

All Articles