1.向空数组内push一个数组,成为二维数组报错:Uncaught TypeError: Cannot read property ‘push’ of null
因为非数组是无法进行push操作的, 当变量为null时不是数组。
if(self.list) self.list.push(newItem)
else{
self.list[0] = newItem
}
只能分开判断。
1.向空数组内push一个数组,成为二维数组报错:Uncaught TypeError: Cannot read property ‘push’ of null
因为非数组是无法进行push操作的, 当变量为null时不是数组。
if(self.list) self.list.push(newItem)
else{
self.list[0] = newItem
}
只能分开判断。