Created
May 30, 2018 11:01
-
-
Save khg0712/79b9134f13d495afa4f86f8965bdc1b7 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.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