I tried and got the following output:
[object Object]
I am familiar with adding new functions to Object.prototype so that every object in the program inherits that new function. But I am a bit curious to know how this has been implemented. I am guessing Object should of type
{
name: expression,
name: expression,
...
}
I am also guessing Object.prototype should be the key to one of the Object property and the value of that property is ‘[object Object]’. Now would you please let me know if my understanding is correct?
I am also wondering what is the difference between ‘object’ and ‘Object’ in ‘[object Object]’. I am also wondering if any of the above mentioned objects is related to the one preceding ‘.prototype’. Would you please clarify?
When I tried to print Object.prototype.object, Object.prototype.Object, Object.prototype[object], Object.prototype[Object], and Object.prototype[0], I am always getting undefined. If prototype doesn’t have any property, how did I get [object Object]?
The
objectis always there and theObjectcomes from the value of the[[Class]]internal property which is whyIt’s described in 15.2.4.2:
Internal properties are a bit confusing. You can read up on them at 8.6.2:
Incidentally, the
Object.prototype.toString.calltrick is used by jQuery and other libraries in theirisArrayfunctions since the internal property is the same for all frames even though each frame has its own version of theArraybuiltin.