Created
May 30, 2018 11:00
-
-
Save khg0712/19e235627b11fea83f92fa36b2c83cf3 to your computer and use it in GitHub Desktop.
프로토타입 객체의 프로퍼티 변경
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Animal (name) { | |
this.word = function() { | |
console.log("abcd"); | |
}; | |
this.name = name; | |
} | |
var dog = new Animal("James"); | |
dog.word();//abcd 출력 | |
Animal.prototype.bark = function(word) { | |
console.log(word); | |
}; | |
dog.bark('grrrr');//grrrr 출력 | |
Animal.prototype.bark = function() { | |
console.log('brrrr'); | |
} | |
dog.bark();//brrrr 출력 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment