本文介绍了什么是JavaScript中的[1,2,3,4] [1,2]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以通过解释来解释上述问题.我尝试过它的控制台,答案是3
can anyone explains the above question with explanation. I tried it console and the answer coming is 3
[1,2,3,4][1,2] //consoles 3 推荐答案[1,2,3,4] 是数组文字.
1,2 是两个数字,其中逗号之间的运算符,因此解析为 2 .
1,2 is two numbers with a comma operator between them, so resolves to 2.
因此,您将从数组中获得索引2(第三项).
So you are getting index 2 (the third item) from the array.
var array = [1,2,3,4]; var property = (1,2); var result = array[property]; console.log({ array: array, property: property, result: result });
更多推荐
什么是JavaScript中的[1,2,3,4] [1,2]
发布评论