var Game = function(){
var game = this;
game.Player = {
pts:[]
}
}
例如在 php 中它可能是:
game.Computer extends game.Player
但是我怎样才能在同一个班级的 javascript 中从 game.Player 做一个孩子?
[update]
[1]
var Game = function(){
var game = this;
game.Player = {
pts:[],
test: function(){ alert('test'); }
}
Player.prototype = new Computer;
game.Computer = {
}
}
var game = new Game();
game.Computer.test();
我不确定@BenM
[update]
[2]
甚至像这样:
var Game = function(){
var game = this;
game.Player = {
pts:[],
test: function(){ alert('test'); }
}
game.Player.prototype = game.Computer {
}
}
var game = new Game();
game.Computer.test();
那也是错误的,不能按原样扩展它。对不起,如果这里有很多代码。