我正在使用handsontable,但不了解JavaScript。我有:
$container.handsontable({
startRows: 8,
startCols: 6,
rowHeaders: true,
colHeaders: true,
minSpareRows: 1,
contextMenu: true,
afterChange: function (change, source) {
if (source === 'loadData') {
console.log(change);
}
当我查看控制台时,我看到:
[[4, "notes", "PLEASE SET", ""]]
这看起来不像标准对象。 它是什么以及如何访问其参数?
这是一个
数组,其中第一个元素是一个包含 4 个元素的数组。
在浏览器 JavaScript 控制台(按 F12,然后转到控制台)或 jsconsole.com 中尝试此操作:
var arr = [[4, "notes", "PLEASE SET", ""]]; // Initialize the array
console.log (arr[0]); // [4, "notes", "PLEASE SET", ""]
console.log (arr[0][0]); // 4
console.log (arr[0][1]); // "notes"
console.log (arr[0][2]); // "PLEASE SET"
console.log (arr[0][3]); // ""
console.log (arr[0][4]); // undefined
console.log (arr[1]); // undefined
console.log (arr[1][0]); // undefined