alert(
(![]+[])[[]-[]]+
(([]+[])+([][[]]))[[]-[]]+
(([]+[])+([][[]]))[!![]-[]]
);
Heres' the fiddle: http://jsfiddle.net/leeny/6VugZ/
How exactly is this cryptic piece of code working?
“This” keyword refers to an object that is executing the current piece of code. It references the object that is executing the current function. If the function being referenced is a regular function, “this” references the global object.
log() is a function in JavaScript that is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user. Syntax: console. log(" ");
In JavaScript, the this keyword refers to an object. Which object depends on how this is being invoked (used or called). The this keyword refers to different objects depending on how it is used: In an object method, this refers to the object.
vvvvvvv [0]
(![]+[])[[]-[]] = "false"[0]
^^^^^^^^ "false"
vvvvvvv again [0]
(([]+[])+([][[]]))[[]-[]] = "undefined"[0]
^^^^^^^^^^^^^^^^^^ "undefined"
vvvvvvvvv this time [1]
(([]+[])+([][[]]))[!![]-[]] = "undefined"[1]
^^^^^^^^^^^^^^^^^^ again "undefined"
Thus you get "f"+"u"+"n" === "fun"
.
"false"
![]
is false
. +[]
simply acts as a transformation into a string. Thus we gain the string "false"
.
"undefined"
One of the operands needs to be a string. This is being done by []+[]
. The actual undefined
is created in the right hand side: [][[]]
=== [][0]
, the first entry of an empty array is undefined
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With