Javascript – Is it Object Oriented or Prototypical ????

Is javascript Object Oriented or Prototypical language?

This was one of the confusing questions on which I spent a lot of time googling and discussing or rather arguing with my friends. And finally the I could reach a convincing solution which is as follows:

Javascript is an Object Oriented languages. At the same time it employs prototype based programming(which is special style of Object oriented programming) for accomplishing the concept “inhertance”. According to Douglas crockford, the renowned javascript Guru, JavaScript is a class-free, object-oriented language, and as such, it uses prototypal inheritance instead of classical inheritance”

Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse (known as inheritance in class-based languages) is accomplished through a process of decorating existing objects which serve as prototypes. This model is also known as class-less, prototype-oriented, or instance-based programming.

Which means unlike other languages (eg java ,c++) it does not have “Classes”. But it uses functions as classes. In other words defining a class is as simple as writing a function. For instance,

function Animal(){ = “lion”;


Whenever we create a new object using “new”, this method is invoked. So this function can be treated a constructor. For those who insists on classes, this function can be considered as class as well. As convention, Constructor name always start with capital letter.

Eg: var lion = new Animal();