Object Orientated Javascript

JavaScript has strong object-oriented programming capabilities, even though some debates have taken place due to the differences in object-oriented JavaScript compared to other languages.

Terminology


Class


Defines the characteristics of the Object.


Object


An Instance of a Class.


Property


An Object characteristic, such as color.


Method


An Object capability, such as walk.


Constructor


A method called at the moment of instantiation.


Inheritance


A Class can inherit characteristics from another Class.


Encapsulation


A Class defines only the characteristics of the Object, a method defines only how the method executes.


Abstraction


The conjunction of complex inheritance, methods, properties of an Object must be able to simulate a reality model.


Polymorphism


Different Classes might define the same method or property.


JavaScript is a prototype-based language which contains no class statement, such as is found in C++ or Java. This is sometimes confusing for programmers accustomed to languages with a class statement. Instead, JavaScript uses functions as classes. Defining a class is as easy as defining a function. In the example below we define a new class called Person.