Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function dad(){}
  2. dad.prototype.hairColor = "brown"
  3. dad.prototype.changeHair = function(newColor) {this.hairColor = newColor;}
  4.  
  5. child1 = new dad()
  6. child1.changeHair("red")
  7.  
  8. child2 = new dad()
  9. child2.changeHair("blonde")
  10.  
  11. child3 = new dad()
  12. child3.changeHair("purple")
  13.  
  14. print(child1.hairColor)
  15. print(child2.hairColor)
  16. print(child3.hairColor)
  17.  
  18. print("\n\n")
  19. dad.prototype.changeHair("bald")
  20. child4 = new dad()
  21. print("\n\n")
  22.  
  23. print(child1.hairColor)
  24. print(child2.hairColor)
  25. print(child3.hairColor)
  26.  
  27. print(child4.hairColor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement