Object Oriented Programming in Javascript

Object Oriented Programming

Object Oriented Programming (OOP) is a programming paradigm that uses abstraction to create models based on the real world. OOP uses several techniques from previously established paradigms, including modularity, polymorphism, and encapsulation. Today, many popular programming languages (such as Java, JavaScript, C#, C++, Python, PHP, Ruby and Objective-C) support OOP.

OOP envisions software as a collection of cooperating objects rather than a collection of functions or simply a list of commands (as is the traditional view). In OOP, each object can receive messages, process data, and send messages to other objects. Each object can be viewed as an independent little machine with a distinct role or responsibility.

OOP promotes greater flexibility and maintainability in programming, and is widely popular in large-scale software engineering. Because OOP strongly emphasizes modularity, object-oriented code is simpler to develop and easier to understand later on. Object-oriented code promotes more direct analysis, coding, and understanding of complex situations and procedures than less modular programming methods.


Namespace A container which lets developers bundle all functionality under a unique, application-specific name.
 Class Defines the object’s characteristics. A class is a template definition of an object’s properties and methods.
 Object An instance of a class.
 Property An object characteristic, such as color.
 Method An object capability, such as walk. It is a subroutine or function associated with a class.
 Constructor A method called at the moment an object is instantiated. It usually has the same name as the class containing it.
 Inheritance A class can inherit characteristics from another class.
 Encapsulation A method of bundling the data and methods that use the data.
 Abstraction The conjunction of an object’s complex inheritance, methods, and properties must adequately reflect a reality model.
 Polymorphism Poly means “many” and morphism means “forms”. Different classes might define the same method or property.

Prototype-based programming

Prototype-based programming is an OOP model that doesn’t use classes, but rather it first accomplishes the behavior of any class and then reuses it (equivalent to inheritance in class-based languages) by decorating (or expanding upon) existing prototype objects. (Also called classless, prototype-oriented, or instance-based programming.)

The original (and most canonical) example of a prototype-based language is Self developed by David Ungar and Randall Smith. However, the class-less programming style grows increasingly popular lately, and has been adopted for programming languages such as JavaScript, Cecil, NewtonScript, Io, MOO, REBOL, Kevo, Squeak (when using the Viewer framework to manipulate Morphic components), and several others.

In next part of this article, you will learn how to use Object Oriented Programming in javascript.

I hope you will find this post very useful regarding Object Oriented Programming in Javascript. Let me know if you have any question regarding Javascript in the comment . I will reply to you ASAP.

Have you got a cool idea about Web Application Development ? Contact us Now to get a free consultation on your idea. Alphanso Tech is rated as one of the best Web Application Development Company in India.

Post by Milan Sanathara

I am iOS Application Developer with an aspiration of learning new technology and creating a bright future in Information Technology.

Leave a Reply

Your email address will not be published. Required fields are marked *