Net-informations.com
SiteMap  | About    

Is JavaScript Object Oriented?

Object Oriented Programming

There are three major features in object-oriented programming: encapsulation, inheritance and polymorphism.

Encapsulation: Encapsulation refers to the creation of self-contained modules that bind processing functions to the data. These user-defined data types are called "classes," and one instance of a class is an "object."

Inheritance: This is the mechanism by which an object acquires some or all features from one or more other objects.

Polymorphism: Object-oriented programming allows procedures about objects to be created whose exact type is not known until runtime.

Meeting these requirements is what usually allows us to classify a language as Object Oriented.

Is JavaScript Object Oriented?

JavaScript is a prototype-based programming language. A prototype-based programming language is a style of object-oriented programming that uses functions as constructors for classes . Although JavaScript has a keyword class, it has no class statement. Also, it employs cloning and not inheritance.

JavaScript is heavily object-based and an excellent language to write object oriented web applications. JavaScript gives you the ability to make your own objects for your own applications. Regarding Encapsulation , JavaScript objects are entities supporting data and functions, but they haven't an advanced native support to hide internal details. With your objects you can code in events that fire when you want them to, and the code is encapsulated. It can be initialized any amount of times. JavaScript objects do not care about privacy. All the properties and methods are publicly accessible if no caution is taken. Also, in JavaScript we can implement the different types of polymorphism in several ways and maybe we have done it many times unknowingly.

While object-oriented programming languages encourages development focus on taxonomy and relationships, prototype-based programming languages encourages to focus on behaviour first and then later classify.









net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.