JavaScript type coercion with strings and indexing
问题 In the below snippet why does whatDoesItDo() function return "fail" as string? It would be helpful if someone can explain the concept behind such behavior. function whatDoesItDo() { return (![] + [])[+[]] + (![] + [])[+!+[]] + ([![]] + [][ [] ])[+!+[] + [+[]]] + (![] + [])[!+[] + !+[]]; } function result() { document.getElementById("result").innerHTML = whatDoesItDo(); } result(); <html> <body> <p id="result"></p> </body> </html> 回答1: You're seeing the effects of A) Type coercion, B) Indexing