Skip to content

Instantly share code, notes, and snippets.

@khg0712
Created May 30, 2018 11:01
Show Gist options
  • Save khg0712/79b9134f13d495afa4f86f8965bdc1b7 to your computer and use it in GitHub Desktop.
Save khg0712/79b9134f13d495afa4f86f8965bdc1b7 to your computer and use it in GitHub Desktop.
디폴트 프로토타입 객체의 변경
function Animal(name) {
this.name = name;
this.species = "frog"
}
var frog = new Animal("James");
Animal.prototype = {
country: "Korea"
};//Animal 생성자의 프로토타입 객체 변경
var dog = new Animal("Jori");
console.log(frog.name);//James 출력
console.log(dog.name);//Jori 출력
console.log(frog.country);//undefined 출력
console.log(dog.country);//Korea 출력
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment