- From: <bugzilla@jessica.w3.org>
- Date: Sun, 08 Dec 2013 23:15:26 +0000
- To: public-webapps-bugzilla@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24018
--- Comment #2 from Erik Arvidsson <arv@chromium.org> ---
> Does ES6 make it possible to detect whether a function is a "class" or has a constructor?
There is no difference between a class and a function. The only way to tell the
difference is in what Function.prototype.toString would return.
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-function.prototype.tostring
The constructor is always the function representing the class.
```js
class C {}
assert(C === C.prototype.constructor);
class C2 {
constructor() {}
}
assert(C2 === C2.prototype.constructor);
```
Just like `Date === Date.prototype.contstructor` and `HTMLElement ===
HTMLElement.prototype.constructor`.
When writing "classes" using ES3/ES5 libraries such as Closure, Backbone,
Ember, Ext.js, YUI etc they will set up the prototype.constructor so that this
equivalence also holds.
--
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Sunday, 8 December 2013 23:15:27 UTC