An object inherits from Function.prototype, which in turn inherits from Object.prototype.
this is because inside, Object is actually a function
function Object(){[native code]}
so we can write code like
var ob=new Object();
An object inherits properties such as "caller", "arity", etc. from Function.prototype
However (and this is what confuses)
alert(Object.hasOwnProperty('caller'));
shouldn't it return false, since Object actually inherits the caller property from Function.prototype?
Same
alert(Function.hasOwnProperty('caller')); alert(Number.hasOwnProperty('caller'));
So, does anyone have an idea of why this is happening?
Thank you very much. I hope I'm not naive.
EDIT
try Object.getOwnPropertyNames(Object) really returned 'caller' as a property directly directly in Object. So Object.hasOwnProperty('caller') is actually correct
But now the question is why in the MDN documentation 'caller' is referred to as inherited from Function. Thus, this definitely leads to confusion.
So what is the error in the documentation? thanks.
EDIT-2
Can I conclude that Object has its own
caller , length etc. properties like even Object.length and Object.__proto__.length do not match. It should have been equal if Object actually inherited the length property from its [[prototype]] , ie Function.prototype but not in this case
Why does MDN mention that Object only inherits caller , length , arity , etc. from its object [[prototype]] ? its a little misleading IMHO