I hope end of this articles you can gain some depth information regarding the above topics with some new concepts & ideas.
So we start with Introduction of the Object:
Here are some available definition of Object on internet word:-
"An object is a collection of properties, and a property is an association between a name and a value. A property's value can be a function, in which case the property is known as a method. In addition to objects that are predefined in the browser, you can define your own objects."
"An object is an unordered list of primitive data types (and sometimes reference data types) that is stored as a series of name-value pairs. Each item in the list is called a property (functions are called methods). "
Now we start with Custom object with process of Creating Objects:
At the bottom line is that when above code executed, we will have an object named apple whose type is Object. But what, it is like the above simple...
The above created object is not a simple as it looks. So, what we do just look the deep into object and find what happened behind the scene?
When we dive into object found that create object is not independent or can say not alone, it has a connection to the main Object types that it derives from.
So what we got, every custom object derived from base Object.
When we talk about apple is an empty object. While there we don't defined any properties with that. But there is always a special internal property exists with every defined object called _proto_ and often we represent them as [[Prototype]].That properties point to base Object. You can also find that with debugging mode with every object.
Confused? What is happening here or What the [[Prototype]] property reference is what is known as a prototype object.
Now we discussed in details. A prototype object is the reference point of source that another object is based on. If we go through our example, the apple object is created on the base of Object type. How can we prove that, we already knew that apple contains no properties of its own, but due to relation with Object type, we can access any properties the Object contains through apple itself.
Look the following code:
apple.toString(); // [object Object]
In above code we are calling the toString() method with the apple object. But that didn't return any error instead of that return the specific result. But how can this happen? Due to parent/child relation which base Object apple access the properties of base Object.
Now we dive into more depth and find what is happening here?
>> But apple object replied with a, Hey, I don't know what you are talking about. I don't have any information regarding that.
A few milliseconds later, after finding the prototype object thanks to the [[Prototype]] property,
>> The Object replies with "yes and call the toString() method for apple object."
Suggestion are welcome.