我一直在玩javascript多年,但我現在想要認真對待。學習,並進入對象。用不同的方法創建2個其他對象的javascript基礎對象
我想創建一個基礎對象,並用它來創建另外兩個略有不同的對象。
我想這會工作:
function movingObject(x, y, z){
this.x = x;
this.y = y;
this.z = z;
}
var positiveMover = new movingObject(x, y, z);
positiveMover.prototype.move = function(a, b){
yadda yadda
}
var negativeMover = new movingObject(x, y, z);
negativeMover.prototype.move = function(b, a){
adday adday
}
var pic = postiveMover(1, 2, 3);
pic.move(20, 10);
我得到一個未定義的錯誤上舉.....很肯定我有錯誤的想法。任何意見,將不勝感激 - 信息的鏈接,或者合適的關鍵詞,以谷歌
在JavaScript中,'x.prototype'不是「x的原型」。 – georg
我正在將移動功能添加到negativeMover對象 – user3036025