开发者

Why does alert(["a","b","c","d","e"][[1,2],3,4]) output e in javascript?

Could someone tell me why:

alert(["a","b","c","d","e"][[1,2],3,4]) 

o开发者_如何学JAVAutputs e in JavaScript?


Because comma is an operator that executes all of the separated instructions (in fact: two instructions, each of which can also use a comma operator) and returns the results of the last one. I.e.:

["a","b","c","d","e"][[1,2],3,4] => ["a","b","c","d","e"][4] === "e"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜