Why does alert(++[[]][+[]]+[+[]]); print 10?
This question already has an answer here:
Check out jsfuck.com. This gives examples and shows how to, quite literally, write any code using it.
The basics:
false => ![]
true => !![]
undefined => [][[]]
NaN => +[![]]
0 => +[]
1 => +!+[]
2 => !+[]+!+[]
10 => [+!+[]]+[+[]]
Array => []
Number => +[]
String => []+[]
Boolean => ![]
Function => []["filter"]
eval => []["filter"]["constructor"]( CODE )()
window => []["filter"]["constructor"]("return this")()
链接地址: http://www.djcxy.com/p/48054.html