[英]Why people say that javascript doesn't have 2-dimensional arrays?
Why do people say that javascript doesn't have 2-dimensional arrays? 人们为什么会说javascript没有二维数组? Isn't 是不是
[[]]
A 2-dimensional array? 二维数组?
Well, [[]]
is an array containing an array. 好吧, [[]]
是一个包含数组的数组。 Also, [[1],[2,3]]
is an array containing arrays. 另外, [[1],[2,3]]
是包含数组的数组。
Sometimes an array of arrays can be, and is intended to be, interpreted as a 2D array. 有时,数组的数组可以并且打算解释为2D数组。 Other times it's something different. 其他时候则有所不同。
While js clearly allows an array to contain arrays, it doesn't provide any special support for 2D arrays as a complete data structure. 尽管js明确允许数组包含数组,但它并未对2D数组作为完整的数据结构提供任何特殊支持。 What that means to you as a developer probably depends on what you expect out of a 2D array. 作为开发人员,这对您意味着什么,可能取决于您对2D阵列的期望。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.