TIL_class/super

김진경·2020년 3월 25일
0

IM19

목록 보기
10/21
class Human{
	constructor(name){
    	this.name = name;
    }
    sleep(){
    }
}

var steve = new Human('steve');

class Student extends Human{
	constructor(name){
    	super(name);
    }
    learn(){
    }
}
var john = new Student('john');
john.learn();
john.sleep(); // johin is sleeping...

Object.create()와 비교해보자. 더 간단명료해졌다.
어떻게 달라졌는지 비교해보자

profile
Maktub.

0개의 댓글