I can't wrap my mind around this quirk.

我想不起来这个怪癖。

[1,2,3,4,5,6][1,2,3]; // 4
[1,2,3,4,5,6][1,2]; // 3

I know [1,2,3] + [1,2] = "1,2,31,2", but I can't find what type or operation is being performed.

我知道[1、2、3]+[1、2]= "1、2、31、2",但我找不到正在执行的类型或操作。

4 个解决方案

#1


372

[1,2,3,4,5,6][1,2,3];
      ^         ^
      |         |
    array       + — array subscript access operation,
                    where index is `1,2,3`,
                    which is an expression that evaluates to `3`.

The second [...] cannot be an array, so it’s an array subscript operation. And the contents of a subscript operation are not a delimited list of operands, but a single expression.

第二个[…不能是数组,所以它是数组下标操作。下标操作的内容不是限定操作数的列表,而是一个表达式。

Read more about the comma operator here.

在这里阅读更多有关逗号运算符的信息。

更多相关文章

  1. js之DOM操作(访问父节点parentNode)
  2. javascript对iframe的互操作浅析
  3. Python 内置函数及excel操作
  4. 【项目实战】自监控-09-DataFrame索引操作(上篇)
  5. Python文件操作大全,随机删除文件夹内的任意文件
  6. 使用Python操作MongoDB
  7. Cloud Pub / Sub Demo:403未授权用户执行此操作。当试图推送通知
  8. Python 文件的基本操作
  9. python 字符串操作

随机推荐

  1. Android 调用摄像头录视频,用前摄像头预览
  2. Toast显示过程详解
  3. Android Studio如何使用GitHub上的开源项
  4. [置顶] Jenkins构建Android项目持
  5. OpenCV学习笔记(六)—— OpenCV for Androi
  6. 安卓设计模式之_观察者模式
  7. 绑定本地Service和远程Service并调用其中
  8. RecycleView的多视图Epoxy库
  9. 在Eclipse中使用aar文件
  10. Android百度地图开发之获取apikey