Why does alert(++[[]][+[]]+[+[]]); print 10?

This question already has an answer here:

  • Why does ++[[]][+[]]+[+[]] return the string “10”? 8 answers

  • 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

    上一篇: 在javascript中,为什么+ []或+“”等于0

    下一篇: 为什么alert(++ [[]] [+ []] + [+ []]); 打印10?