Determining if an object can be constructed

Hagbard Celine hagb4rd at gmail.com
Fri Jan 20 11:43:01 UTC 2017


a reflection on if and how "this" is used inside a function, would
reveal what inner-interface it uses to some object, also also if it
mutates its properties. every function mutating this-bound objects is
potentiallyt a cinstructor. afaik:

new Foo(); is aequivalent to Foo.call(Object.create(Foo.prototype))
with an implicit "return this" at Foo"s end.



On 1/20/17, Michał Wadas <michalwadas at gmail.com> wrote:
> It would be equivalent to solving halting problem.
>
> Any function like "isConstructor" have to return three possible values -
> "yes" (native constructors, classes without constructor), "maybe" (can't
> determine), "no" (arrow functions, methods, generators).
>
> On 20/01/17 04:03, Scott Sauyet wrote:
>> if there was any way to distinguish a function like this
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the es-discuss mailing list