javascript-questions icon indicating copy to clipboard operation
javascript-questions copied to clipboard

Need clarification on Question 14.

Open romaannaeem opened this issue 5 years ago • 4 comments

The answer mentions the base object has no prototype, yet can still go down the prototype chain to find methods/properties. Doesn't the existence of the __proto__ object mean that this base object has a prototype?

romaannaeem avatar Dec 09 '20 15:12 romaannaeem

+1

canguser avatar Dec 22 '20 09:12 canguser

Should be interpreted as null or undefined instead of the basic object

canguser avatar Dec 22 '20 09:12 canguser

The base object is the object created by the user, or an object that is created using the new keyword.

Agreed that the explanation has some problems. The above sentence sounds like the plain object, but in fact, I think the author means Object.prototype.

> Object.getPrototypeOf({})
{}
> Object.getPrototypeOf(Object.prototype)
null

chinesedfan avatar Jan 14 '21 12:01 chinesedfan

Well, I am happy to get stuck on this while learning too. the answer definitely needs to be reviewed. anyway good learning, I won't hold it against myself not getting this question -:)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain https://stackoverflow.com/questions/801032/why-is-null-an-object-and-whats-the-difference-between-null-and-undefined

It seems only null does not have a prototype, yet null is kind of a special case in itself.

efleurine avatar Dec 07 '21 16:12 efleurine