In Javascript, any "function object" has a prototype
> F = function() {}
F()
> F.prototype
F {}
But "object" or "instance" doesn't have a prototype
> o = {}
Object {}
> o.prototype
undefined
> f = new F()
F {}
> f.prototype
undefined
However, the built-in object "Function" and "Object" have a prototype:
> Function.prototype
Empty()
> Object.prototype
Object {}
This looks quite confusing for me.
Functionand "function object" have a prototype propertyObjecthas a prototype property, but "object literal" and "instance object" doesn't have a prototype property
What does the prototype property actually mean? In the example above, shouldn't the prototype property of f be F?
Does anyone have ideas about how to explain this? Thanks!
ObjectandFunctionare functions (constructors). Note "object" (as in{}) vs "Object" as in anything that is a JavaScript object.