I am trying to get to the bottom of javascript object, prototypes etc.
I have a fairly good grasp of it, but I get confused the closer I get to the base object.prototype.
First of all, I was under the impression that all objects descend directly from Object. But some objects (like Array) seem to inherit properties and methods from the function.prototype as well. So does this mean that the chain is like this:
object -- function -- array ?
Second, I noticed (on the mozilla javascript reference site) that object.prototype inherits properties and methods from function.prototype and vice versa!?
How can this be? I must be missing something important about understanding the chain?
Can someone explain these two issues to me?
I have a fairly good grasp of it, but I get confused the closer I get to the base object.prototype.
First of all, I was under the impression that all objects descend directly from Object. But some objects (like Array) seem to inherit properties and methods from the function.prototype as well. So does this mean that the chain is like this:
object -- function -- array ?
Second, I noticed (on the mozilla javascript reference site) that object.prototype inherits properties and methods from function.prototype and vice versa!?
How can this be? I must be missing something important about understanding the chain?
Can someone explain these two issues to me?