Determining if an object can be constructed

Till Schneidereit till at tillschneidereit.net
Thu Jan 19 15:05:36 UTC 2017


It's not, in that it has bugs like all of them. It's obviously unfortunate
that the fix for this particular bug hasn't landed yet.

On Thu, Jan 19, 2017 at 3:22 PM, Andrea Giammarchi <
andrea.giammarchi at gmail.com> wrote:

> Doh! Good point ... I didn't know Firefox was different from every other
> modern engine :-/
>
> On Thu, Jan 19, 2017 at 2:16 PM, Claude Pache <claude.pache at gmail.com>
> wrote:
>
>>
>> Le 19 janv. 2017 à 13:46, Andrea Giammarchi <andrea.giammarchi at gmail.com>
>> a écrit :
>>
>> If you are looking for isClass or similar you can also rely on
>> `Function.prototype.toString` decompilation, which is de facto consistent.
>>
>> ```js
>> const isClass = (fn) =>
>>   typeof fn === 'function' &&
>>   !isClass.toString.call(fn).indexOf('class ');
>> ```
>>
>> Of course if you transpile code, including classes, that'd be useless
>> (but then you'll have many other problems anyway)
>>
>>
>> It is also useless when `Function#toString()` is not correctly
>> implemented, which is currently the case for Firefox, see:
>> https://bugzilla.mozilla.org/show_bug.cgi?id=1216630
>>
>> —Claude
>>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170119/e5b9ab31/attachment.html>


More information about the es-discuss mailing list