Skip to content

Instantly share code, notes, and snippets.

@khg0712
Created May 30, 2018 11:00
Show Gist options
  • Save khg0712/19e235627b11fea83f92fa36b2c83cf3 to your computer and use it in GitHub Desktop.
Save khg0712/19e235627b11fea83f92fa36b2c83cf3 to your computer and use it in GitHub Desktop.
프로토타입 객체의 프로퍼티 변경
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