Ben Bacarisse
2/26/2015 3:38:00 PM
Thomas 'PointedEars' Lahn <PointedEars@web.de> writes:
> Ben Bacarisse wrote:
>
>> denissavenok@gmail.com writes:
>>> The function doesn't work as expected. Why?
>>>
>>> var isUndefinedOrNull = function(obj) {
>>> return /^(?:undefined|null)$/.test(typeof obj);
>>> };
>>
>> If the type of obj is Null, typeof is defined to yield 'object'.
>>
>> You might (in some very odd implementation) get 'null' from typeof, but
>> that's only because the result is up to the implementation in some very
>> specific cases.
>
> To be exact, a conforming implementation of ECMAScript could only provide
> "null" as the result of a â??typeofâ? operation if the operand was a reference
> to a host object.
To be more exact, only if the reference is to a host object that does
not implement [[Call]]. For references to callable object, both native
and host, the result must be 'function'.
<snip>
--
Ben.