Function constants for Identity and No-op
Peter van der Zee
ecma at qfox.nl
Wed Aug 10 15:46:21 UTC 2016
>> What's the issue with document.createElement('object')?
> It's a callable exotic object.
>> Function.isFunction? :D
> typeof is what you are looking for.
There is precedent (at least in IE ) for exotic functions where
`typeof` returned "unknown". Could happen for any exotic value unless
the spec changed on that. An `isFunction`, or rather, a simple
`isCallable`, may not be that far off the mark and is in line with the
existing `isArray`. Though I'd much rather have callables invariantly
locked down to being "typeof function". Even if that means explicit
exceptions to some legacy cases.
PS. Regexes in firefox were "callable" and had typeof function, but I
think that's so far back  it's not super relevant here. Of course
the same could be said about the IE case.
; one of many examples:
More information about the es-discuss