Javascript: Typeerror: ... Is Not A Constructor
I have a TypeError problem: function artist(name) { this.name = name; this.albums = new Array(); this.addAlbum = function(albumName) { for (var i = 0; i < t
Solution 1:
This line
var album = new album(albumName);
shadows the external album
function. So yes, album
isn't a constructor inside the function. To be more precise it's undefined
at this point.
To avoid this kind of problem, I'd suggest naming your "classes" starting with an uppercase :
functionAlbum(name) {
More generally I'd suggest to follow the Google style guide when in doubt.
Post a Comment for "Javascript: Typeerror: ... Is Not A Constructor"