javascript - TypeError: Cannot read property '0' of undefined -


when call renderframe, trying access newline[i] throws error of

uncaught typeerror: cannot read property '0' of undefined 

why this? i've included relevant code.

rows : ["-","-","-","-","-","-","-","-","-","-",],  generateline : function(){     var result = new array(10);     for(var = 0; < result.length; i++){         result[i] = " ";     } },  renderframe : function(){     var newline = this.generateline();     for(var = 0; < this.rows.length; i++){         console.log(newline[i]);     } }, 

you forgot

return result; 

at end of generateline()

so newline undefined. hence cannot read property '0' of undefined


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -