If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Ok, so we know that when we use math operators on an empty array it outputs 0.

Operators
There are two special operators in the original code: "~" and "<<". These are called Bitwise Operators.

The ~ operator is called the Bitwise NOT. It inverts the bits of a number.

Code:

var x = 10;
pLog(x); //number(10)
pLog(~x); //number(-11)

You may notice that this operator is the equivalent of the math function -(N + 1)

The << is the Left Shift operator. It shifts a number in binary representation N bits to the left, shifting in zeroes from the right.
If you don't understand any of this, I'd recommend researching binary numbers.

Code:

var x = 3;
pLog(x); //number(3)
pLog(x<<3); //number(24)

The decimal number 3 is represented as "11" in binary.
If you shift that to the left by 3 places, padding with zeroes that'd be binary "11000" which is 24!

Breaking down the actual code
First thing to do is make it a bit more readable -

Code:

+[[ -~[] << ~[] ][+[]] + []][ +[] ][ ++[[]][ +[] ] + [+[]] ]

Ok so we know that when we use math operators on an empty array it gives 0
We also know that ~ is basically -(N + 1)
so+[] == 0
and~[] == ~0~0 == -1

So we know that +[] is zero and ~[] is negative one.
The minus before the ~[] simply changes it from a negative to a positive number (double negative).

Going through and replacing those through the code we get

Code:

+[[ 1 << -1 ][0] + []][0][ ++[[]][0] + [0] ]

Definitely looking a bit more readable.
Notice the ++[[]][0]

If we have an array -

Code:

var x = [10, 2];

We know that x[0] will return the first value of the array.

So [[]] is the array and [0] returns the first value of that array (which is [], an empty array)
Since +[] is 0 and ++ is the incremental operator, ++[] gives us 1.

So -2147483648 + [] actually just converts -2147483648 into the string "-2147483648".

Code:

+["-2147483648"][0][ 1 + [0]]

Notice the last part of the code: [1 + [0]]
If it were [1 + 0] that would evaluate to 1.
However, because [0] is treated as the string "0", it is concatenated onto the number 1. (Have a read through this link if you'd like)
This gives us

Code:

+["-2147483648"][0]["10"]

Now the [0] gives us the first value of the array.
However its not the same as this

Code:

+"-2147483648"["10"]

because in that cause the + converts the string to a number instantly.

Another neat trick is that you can get the Nth character of a string by accessing it as if it were an array.

Code:

var x = "testing123";
pLog(x[3]); //string(t)

However, in Javascripts arrays aren't really arrays, they're objects.
When you're accessing an object property you can do it two different ways