[英]Undestanding double bracket operation in Javascript
What does [1,2,3][1,2] means in Javascript? [1,2,3][1,2] 在 Javascript 中是什么意思? I do not understand what its supposed to do, and i have no clue how could i google such thing.我不明白它应该做什么,我不知道我怎么能用谷歌搜索这样的东西。
Any ideas?有任何想法吗?
I assume this is quite the newbie question, please forgive my ignorance.我认为这是新手问题,请原谅我的无知。
[1,2,3]
is an Array literal [1,2,3]
是一个数组字面量<obj>[p]
is the bracket notation for property access <obj>[p]
是属性访问的括号表示法1, 2
is a comma operator expression that evaluates to 2
1, 2
是一个逗号运算符表达式,计算结果为2
So the [1,2,3][1,2]
as a whole accesses the index 2
of the array, and yields 3
.所以[1,2,3][1,2]
作为一个整体访问数组的索引2
,并产生3
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.