在下面的代碼片段中,爲什麼whatDoesItDo()
函數返回「fail」作爲字符串? 如果有人能夠解釋這種行爲背後的概念,這將是有益的。帶字符串和索引的JavaScript類型強制
function whatDoesItDo() {
return (![] + [])[+[]] + (![] + [])[+!+[]] +
([![]] + [][
[]
])[+!+[] + [+[]]] + (![] + [])[!+[] + !+[]];
}
function result() {
document.getElementById("result").innerHTML = whatDoesItDo();
}
result();
<html>
<body>
<p id="result"></p>
</body>
</html>
。什麼是你的預期輸出? –
「失敗」是輸出。但問題是爲什麼? – Flake
謎題應該去http://codegolf.stackexchange.com/ –