Javascript 函数调用以[0][0]结尾

Javascript 函数调用以[0][0]结尾,javascript,Javascript,有人能告诉我函数调用末尾的[0][0]用于什么吗? 以下是我的函数的标题: var sensor = _this.createSensor("svg", mouse, "sensor_" + timestamp.substring(2, timestamp.length - 2))[0][0]; createSensor函数可能返回一个数组数组。例如: [['item1','item2',['something1']] 所以本质上它是从第一个数组中选择第一个项。在这种情况下,item1函数可能

有人能告诉我函数调用末尾的[0][0]用于什么吗?

以下是我的函数的标题:

var sensor = _this.createSensor("svg", mouse, "sensor_" + timestamp.substring(2, timestamp.length - 2))[0][0];

createSensor
函数可能返回一个数组数组。例如:

[['item1','item2',['something1']]


所以本质上它是从第一个数组中选择第一个项。在这种情况下,
item1

函数可能返回一个数组数组。例如:

[['item1','item2',['something1']]


所以本质上它是从第一个数组中选择第一个项。在这种情况下,
item1

意味着函数返回一个数组,第一个
[0]
获取对第一个数组元素的引用。然后,该元素本身就是一个数组,因此第二个
[0]
获取该数组的第一个元素

函数foo(){
变量a=[[1,2,3],[4,5,6];
//调用此函数将返回由两个数组组成的数组
返回a;
}
//运行函数并从第一个数组中获取第一项
console.log(foo()[0][0]);//1.
//运行函数并从第二个数组中获取第三项

console.log(foo()[1][2]);//6
这意味着函数返回一个数组,第一个
[0]
获取对第一个数组元素的引用。然后,该元素本身就是一个数组,因此第二个
[0]
获取该数组的第一个元素

函数foo(){
变量a=[[1,2,3],[4,5,6];
//调用此函数将返回由两个数组组成的数组
返回a;
}
//运行函数并从第一个数组中获取第一项
console.log(foo()[0][0]);//1.
//运行函数并从第二个数组中获取第三项
console.log(foo()[1][2]);//6
似乎:

DragSensorController.prototype.createSensor = function (parent, startPoint, id, ip, typeid, timestamp) {
返回数组的数组,如:

_this.createSensor("svg", mouse, "sensor_" + timestamp.substring(2, timestamp.length - 2))
要访问它,您需要使用
[0][0]

const data=[['foo']];
console.log(数据[0][0])似乎:

DragSensorController.prototype.createSensor = function (parent, startPoint, id, ip, typeid, timestamp) {
返回数组的数组,如:

_this.createSensor("svg", mouse, "sensor_" + timestamp.substring(2, timestamp.length - 2))
要访问它,您需要使用
[0][0]

const data=[['foo']];

console.log(数据[0][0])2D数组访问?2D数组访问?可能说类似数组的对象更正确。@艾米,我们真的不知道,但就这个问题而言,这无关紧要。可能说类似数组的对象更正确。@艾米,我们真的不知道,但就这个问题而言,这无关紧要。