我正在尝试比较工作表中不同页面的数组,但是当比较2个完全相同的值时,它总是返回false
function test123() {
var ScanningThisArray = [["123"],["321"],["515"]];
var ActiveEmployeeArray = [["123"],["321"],["515"]];
for (var i = 0; i < ScanningThisArray.length; i++) {
for (var k = 0; k < ActiveEmployeeArray.length; k++) {
Logger.log(ScanningThisArray[i]+" == "+ActiveEmployeeArray[k]+" == "+(ScanningThisArray[i]==ActiveEmployeeArray[k]))
}
}
}
返回
[19-06-18 23:48:18:187 EEST] 123 == 123 == false
[19-06-18 23:48:18:187 EEST] 123 == 321 == false
[19-06-18 23:48:18:188 EEST] 123 == 515 == false
[19-06-18 23:48:18:188 EEST] 321 == 123 == false
[19-06-18 23:48:18:189 EEST] 321 == 321 == false
[19-06-18 23:48:18:189 EEST] 321 == 515 == false
[19-06-18 23:48:18:190 EEST] 515 == 123 == false
[19-06-18 23:48:18:190 EEST] 515 == 321 == false
[19-06-18 23:48:18:191 EEST] 515 == 515 == false
答案 0 :(得分:1)
结果是我正在比较数组与数组,因为google为每个单元格返回了数组,然后将其放入另一个数组,更改为
ScanningThisArray[i]==ActiveEmployeeArray[k]
到
ScanningThisArray[i][0]==ActiveEmployeeArray[k][0]
现在可以正常工作