创建新实例后,我想创建一个新数组作为对象的属性。但我在 Chrome 中收到以下错误:“Uncaught TypeError: Cannot call method 'push' of undefined”。玩家似乎不为人知。但为什么?
function Team(name) {
this.Name = name;
this.Players = new Array();
}
Team.prototype.AddPlayer = new function (player) {
this.Players.push(player); //error
}