search

Home  >  Q&A  >  body text

The meaning of {}, +{}, [], +[] in javascript

function test(){
    return (+{}+[])[1]; //返回a
}

It’s like the above js code. What I want to know is why the return value is "a"?

阿神阿神2798 days ago615

reply all(1)I'll reply

  • 阿神

    阿神2017-05-19 10:42:20

    +{}=NaN,NaN+[]="NaN","NaN"[1]=a

    reply
    0
  • Cancelreply