Syntax Terms Objects
If its not a primitive (undefined, null, boolean, number or string)
its an object.
- Classes and prototypes were invented for two purposes.
- First is encapsulation.
For instance you would create Person class containing person data
like: name, surname, age and address.
Then for each specific person you would create object of that class &
store specific data for that person in that object.
- Second is inheritance.
If you need a class with single additional data or function then
some other class you can simply say to inherit all
peroperties and methods from that class and then define only
additional properties and methods.
- Functions also have a prototype property, which is the initial
__proto__ for any objects created by them.
- When a function is created, it is given a unique object for
- When Object is created from another Object all propertie are copied.
- But properties belonging to parent prototype are not copied just
- Additional Tutorials:
Create Using new keyword
Create Using Object Literal
Create Using Function
- Objects Defining/Referencing Properties