문제

Compared to the actual way of creating "classes" in Javascript as such:

function MyClass(){
}

MyClass.prototype.yada = function(){};

to the new ES6 class

class MyClass {

  yada(){
  }
}

Couldn't find any performance comparisions, but I'm really interested in __proto__/Object.setPrototypeOf inheritance than only the "class sugar" that ES6 offers.

도움이 되었습니까?

해결책

ES6 classes are really just syntactic sugar for constructor functions and prototype initialisations. That is, both versions of your MyClass definition are pretty much equivalent, and will very likely have identical performance characteristics in all implementations (not that there is one yet).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top