Why does this print out 10?

This question already has an answer here:

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

  • You can use only six different characters to write and execute any JS code. For example here are some representations to JS constructs

    false       =>  ![]
    true        =>  !![]
    undefined   =>  [][[]]
    NaN         =>  +[![]]
    0           =>  +[]
    1           =>  +!+[]
    2           =>  !+[]+!+[]
    10          =>  [+!+[]]+[+[]]
    Array       =>  []
    Number      =>  +[]
    String      =>  []+[]
    Boolean     =>  ![]
    Function    =>  []["filter"]
    eval        =>  []["filter"]["constructor"]( CODE )()
    window      =>  []["filter"]["constructor"]("return this")()
    

    Proof at JS F*ck and detail at Why does ++[[]][+[]]+[+[]] return the string "10"?

    链接地址: http://www.djcxy.com/p/48052.html

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

    下一篇: 为什么打印出10张?