How does a custom created object have access to methods such as .toString()
method which is an Object method. How is a custom class linked to an Object
This article states
All objects ultimately have the Object constructor at the end of their prototype chain. This means any methods or properties added to the Object property are automatically available to all objects.
In the previous example, if we called rufus.toString(), javascript would check the rufus object, then the Cat object, then the Pet object. The Pet object’s prototype was created with the Object constructor (using the object literal shortcut) so javascript would then find the toString() method on the Object’s prototype
Now after reading through the article I understand that in order to inherit from an object we have to specify in the prototype of the function constructor of an object the object we would like to inherit from. Now I read that by default the prototype property is empty.Then how can an object have the property toString() ? I dont understand the statement
The Pet object’s prototype was created with the Object constructor (using the object literal shortcut)
Update:
I read that the prototype property of the constructor function is empty by default. I read that here I have pasted the quote here
First, every JavaScript function has a prototype property (this property is empty by default), and you attach properties and methods on this prototype property when you want to implement inheritance.
How do we inherit from the javascript Object then ?