Closed bengl closed 7 years ago
Builtins.typeof(Foo)
=== 'object'
.. because Foo
itself is not an instance of a built-in (not counting 'Object')
Builtins.typeof(Foo.prototype)
=== 'object'
... same reason
Builtins.is(Foo.prototype)
=== true
Builtins.is(Foo.bar)
... depends on the assigned value of bar
. If the assigned value is a built-in, then Builtins.is(Foo.bar)
=== true
Note, We would need to decide if Builtins.is(undefined)
returns true
or false
. I don't have a great answer for that yet.
"undefined" has no constructor, so I'll say "false".
Builtins.typeof(Foo)
==='object'
.. becauseFoo
itself is not an instance of a built-in (not counting 'Object')
Foo
is a constructor, so 'function'
, right?
Builtins.is(Foo.prototype)
===true
Hmm, I would have thought false
, for the same reason as Foo.bar
, also noting the Date
example:
const m = {};
Object.setPrototypeOf(m, Date); // note that this isn't setting it to Date.prototype
Builtins.is(m); // true
Yeah that makes sense re Builtins.is(Foo.prototype)
... it really depends on what the assigned value is
Oh.. and yes, sorry, assuming Foo
is a constructor, Builtins.typeof(Foo)
would be function
Closing as answered
What would the following return, assuming
Builtins.is(Foo) === true
andFoo
is some constructor?Builtins.typeof(Foo)
Builtins.typeof(Foo.prototype)
Builtins.is(Foo.prototype)
Builtins.is(Foo.bar)
(i.e. some property ofFoo
)