当我打电话时renderFrame
,尝试访问newLine[i]
会引发错误
Uncaught TypeError: Cannot read property '0' of undefined
为什么是这样?我已经包含了相关的代码。
rows : ["-","-","-","-","-","-","-","-","-","-",],
generateLine : function(){
var result = new Array(10);
for(var i = 0; i < result.length; i++){
result[i] = " ";
}
},
renderFrame : function(){
var newLine = this.generateLine();
for(var i = 0; i < this.rows.length; i++){
console.log(newLine[i]);
}
},