다른 언어 배우다 웹 관심 생겨서 자스 배우는데


ECMAScript 5랑 ECMAScript 6이랑 별 차이 없는 줄 알고 버전 5로 읽고 있었거든


책 읽는 도중에 알아챘는데 내가 전에 찍먹으로 배운 기억이랑은 전혀 다른 거임


그래서 찾아봤는데 레전드임ㅋㅋ


이게 일단 우리가 알고 있는 친근한 자스


class Base { constructor(val0, val1) { this.val0 = val0; this.val1 = val1; } method0(/* args */ ) {/* implementation */} method1(/* args */ ) {/* implementation */} } class Derived extends Base { constructor(val0, val2, val2) { super(val0, val1); this.val2 = val2; } } let d = new Derived(1, 2, 3); d.method0(/* args */);


이게 ECMAScript 5에서 클래스 선언 할 때


function Base(val0, val1) { this.val0 = val0; this.val1 = val1; } Base.prototype = { method0: function(/* args */) {/* implementation */} method1: function(/* args */) {/* implementation */} }; function Derived(val0, val1, val2) { Base.call(this, val0, val1); this.val2 = val2; } let d = new Derived(1, 2, 3); d.method0(/* args */);


function 선언으로 클래스 구현하는 거 보고 부랄을 탁 쳤다.


저게 버전 6에서 추상화로 어느 정도 해결돼서 많이 쓰이는 면도 있지 않을까?