Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dad(){}
- dad.prototype.hairColor = "brown"
- dad.prototype.changeHair = function(newColor) {this.hairColor = newColor;}
- child1 = new dad()
- child1.changeHair("red")
- child2 = new dad()
- child2.changeHair("blonde")
- child3 = new dad()
- child3.changeHair("purple")
- print(child1.hairColor)
- print(child2.hairColor)
- print(child3.hairColor)
- print("\n\n")
- dad.prototype.changeHair("bald")
- child4 = new dad()
- print("\n\n")
- print(child1.hairColor)
- print(child2.hairColor)
- print(child3.hairColor)
- print(child4.hairColor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement