Accesssing ES6 class constructor function

Oriol _ oriol-bugzilla at
Thu Jan 5 18:06:28 UTC 2017

> It means testing something for typeof "function" no longer guarantees it can be invoked without error.

This has never been a guarantee. Consider this code

function Test() {
  throw new TypeError();
typeof Test === 'function';  // true
Test();  // TypeError

About the stringifications problems, I don't understand what you are attempting to do. Usually you shouldn't need to stringify a function. Probably there is a better approach.

> There seems to be no method [...] to invoke a class constructor except by creating an instance of the class.

Well, the point of constructors is creating instances. If you don't want the instance you can just discard it, but then why call the constructor?

> So classes are fundamentally different than prototype contructors in how we can use them, far more than syntactic sugar

Not that different. You can usually translate one syntax to the other, but you may need ES6 features like ``, `super` or `setPrototypeOf`.

-- Oriol

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list