Subclassing in ES6 - Javascript
기존의 ES5와는 달리, ES6에서 subclassing을 하는 방법을 알아본다. class Human { //function으로 생성자 함수를 만들지 않고, class 라는 명령어로 만든다. constructor(x,y) { //class 명령어로 생성될 것의 property를 지정해준다. this.x = x; this.y = y; } move(){ //prototype이 지닐 method를 생성해준다. this.x++; this.y++; } } class rumee extends Human { // extends를 통하여 Human이 가진 prototype 객체를 복사 붙여넣기 해준다. constructor는 rumee로 유지된다. constructor(x,y) { super(x,y) //super를..
Programming/Concept
2019. 6. 9. 18:22