Javascript中不可靠的双支架操作 [英] Undestanding double bracket operation in Javascript
本文介绍了Javascript中不可靠的双支架操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
[1,2,3] [1,2]在Javascript中的含义是什么?
我不明白它应该做什么,我不知道我怎么可以谷歌这样的事情。
What does [1,2,3][1,2] means in Javascript? I do not understand what its supposed to do, and i have no clue how could i google such thing.
任何想法?
我认为这是一个非常新手的问题,请原谅我的无知。
I assume this is quite the newbie question, please forgive my ignorance.
推荐答案
-
[1,2,3]
是 Array literal -
< obj> [p]
是括号表示法用于属性访问 -
1,2
是逗号运算符表达式,其计算结果为2
[1,2,3]
is an Array literal<obj>[p]
is the bracket notation for property access1, 2
is a comma operator expression that evaluates to2
所以 [1,2,3] [1,2]
作为一个整体访问数组的索引 2
,并且得到 3
。
So the [1,2,3][1,2]
as a whole accesses the index 2
of the array, and yields 3
.
这篇关于Javascript中不可靠的双支架操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文