Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let Lucky=function(kind,body,name,character){//子類別
- Person.call(kind,body);//第一個步驟,呼叫母類別對子類別初始化
- this.name=name;
- this.character=character;
- }
- Lucky.prototype=Object.create(Person.prototype);//第二個步驟,建立物件連結Person的prototype並讓子類別繼承
- Lucky.prototype.constructor=Worker.constructor;//第三個步驟,將建構函數指向自己
- Lucky.prototype.bark=function(){//會覆蓋原型物件的函式內容
- console.log("woof~woof~);
- }
- Lucky.prototype.shakehand=function(){
- console.log(this.name+ "shakes hand with you.");
- }
Add Comment
Please, Sign In to add comment