ES6 class 키워드로 구현하는 constructor 기계
class 부모 {
constructor(){
this.name = 'Kim'
}
}
var 자식 = new 부모();
class 작명{
constructor(){
this.~~~ = ~~~
}
}
class 부모 {
constructor(){
this.name = 'Kim';
this.sayHi = function(){ console.log('hello') }
}
}
var 자식 = new 부모();
class 부모 {
constructor(){
this.name = 'Kim';
}
sayHi(){
console.log('hello')
}
}
var 자식 = new 부모();
1번과 2번의 차이점 : 1번 방법은 obj에 함수가 저장되는것이고 2번 방법은 유전자에만 남는것임