我有一个 TypeError 问题:
function artist(name) {
this.name = name;
this.albums = new Array();
this.addAlbum = function(albumName) {
for (var i = 0; i < this.albums.length; i++) {
if (this.albums[i].name == albumName) {
return this.albums[i];
}
}
var album = new album(albumName);
this.albums.push(album);
return album;
}
}
function album(name) {
this.name = name;
this.songs = new Array();
this.picture = null;
this.addSong = function(songName, track) {
var newSong = new songName(songName, track);
this.songs.push(newSong);
return newSong;
}
}
给出以下错误:
TypeError: album is not a constructor
我找不到问题。我阅读了很多其他帖子,但我找不到类似的问题。难道是不允许在另一个对象中创建一个对象?我该如何解决这个问题?