JavaScript Syntax Terms Objects

 

- Info:

- JavaScript is OOP Object Oriented Programming language.

But JavaScript has no classes and uses prototypes instead.

- JavaScript object is unordered collection of key-value pairs.

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.

- This tutorial is based on http://www.crockford.com/javascript/inheritance.html

 

- Every object in JavaScript has a prototype, accessible through the __proto__ property.

- 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 prototype.

 

- When Object is created from another Object all propertie are copied.

- But properties belonging to parent prototype are not copied just referenced.

 

- Additional Tutorials:

- Inheritance

- Prototype

- Objects Create Using new keyword

- Objects Create Using Object Literal

- Objects Create Using Function

- Objects Defining/Referencing Properties