jasnell / proposal-istypes

TC-39 Proposal for additional is{Type} APIs
201 stars 7 forks source link

two-arg `is` applies to prototype chain as well? #20

Closed bengl closed 7 years ago

bengl commented 7 years ago

When called with a single argument, the Builtins.is() function returns true if the given value is either a built-in object or has a built-in object within its prototype chain.

but

The Builtins.is() function must return false if any of the given values are not built-in objects, or are not the same built-in object. (TODO: Need a better definition of "same").

The two-argument case, for consistency with the one-argument case, should probably include the "or has a built-in object within its prototype chain" bit.

jasnell commented 7 years ago

Yeah, good catch. The two argument version does search the prototype chain also... Essentially, if the two values either are the same built-in, or are descendents of the same built-in, is() returns true

jasnell commented 7 years ago

this has been since refactored