You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interesting question of semantics - I'd argue that it's wrong, because your example does have a prototype, and that prototype is the null value (after all, typeof null is "object").
But then, wouldn't the original also be wrong because the prototype of the base object is null too? 'All objects have prototypes, except for the base object.' suggests it doesn't have one (or that having null as a prototype is equivalent to not having one).
From MDN - "The prototype of Object.prototype is null, so it's at the end of the prototype chain"
So, based on the phrasing of the initial statement it is suggested that objects must have a prototype, and cannot be like the base object which 'does not have one'... which is not correct.
Yeah I don't consider the original explanation to be correct either. It kind of depends on what you consider to be an "object" - is null an object, since it has typeof "object"? Or are we saying "object" is any non-primitive? If it's the former, then "false" is correct, with "null" being the counter example. Otherwise, "true" would be correct, because every non-primitive has a prototype (but that prototype can be a primitive, so there doesn't have to be an infinite depth prototype chain - but there can be!).
You say:
This is incorrect. It's trivial to create an object without a prototype...
The text was updated successfully, but these errors were encountered: