@[TOC](排错日记:js二维数组TypeError: Cannot read properties of undefined (reading ‘2’)) 错误 出错代码 分析 二维数组行坐标越界,导致data[nextRow][col] 值为undefined。 当while判断结束时,存在nextRow = len(len为数组长度) 当访问data[len][col] 是导致越界。 解决思路 让while判断结束时,nextRow最大值为len-1