Guest User

Untitled

a guest
Jan 24th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. let Lucky=function(kind,body,name,character){//子類別
  2. Person.call(kind,body);//第一個步驟,呼叫母類別對子類別初始化
  3. this.name=name;
  4. this.character=character;
  5. }
  6. Lucky.prototype=Object.create(Person.prototype);//第二個步驟,建立物件連結Person的prototype並讓子類別繼承
  7. Lucky.prototype.constructor=Worker.constructor;//第三個步驟,將建構函數指向自己
  8. Lucky.prototype.bark=function(){//會覆蓋原型物件的函式內容
  9. console.log("woof~woof~);
  10. }
  11. Lucky.prototype.shakehand=function(){
  12. console.log(this.name+ "shakes hand with you.");
  13. }
Add Comment
Please, Sign In to add comment