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.
Related Topics
- JavaScript Interview Questions (Part2)
- JavaScript Interview Questions (Part3)
- Advantages and Disadvantages of JavaScript
- Difference Between JavaScript and ECMAScript?
- What is noscript tag?
- Escaping Special Characters in JavaScript
- What is undefined x 1 in JavaScript?
- JavaScript : Logical Operators
- Difference between '=', '==' and '===' operators?
- How to reload a page using JavaScript?
- How to write html code dynamically using JavaScript?
- How to add html elements dynamically with JavaScript?
- How to load another html page from javascript?
- What Is The Disadvantages Using InnerHTML In JavaScript?
- What is Browser Object Model
- How to detect the OS on the client machine in JavaScript?
- Difference between window, document, and screen in Javascript?
- Difference between the substr() and substring() in JavaScript?
- How to replace all occurrences of a string in JavaScript?
- How to test a string as a literal and as an object ?
- What is Associative Array? How do we use it?
- What is an anonymous function in JavaScript?
- What is the use of 'bind' method in JavaScript?
- Pure functions Vs. Impure functions in javascript
- Is Javascript a Functional Programming Language?
- What's the Difference Between Class and Prototypal Inheritance?
- Javascript, Pass by Value or Pass by Reference?
- How to prevent modification of an object in Javascript?
- What is 'this' keyword in JavaScript?
- How Does Function Hoisting Work in JavaScript?
- What do mean by NULL in Javascript?
- What does the delete operator do in JavaScript?
- What is the Infinity property used for in Javascript?
- Event bubbling and Event Capturing in JavScript?
- What is "strict mode" and how is it used in JavaScript?
- What is the difference between .call() and .apply()?
- Entire content of a JavaScript source file in a function block?
- What is an immediately-invoked function expression?
- What is escape & unescape String functions in JavaScript?
- What is the instanceof operator in JavaScript?
- What Are RESTful (REpresentational State Transfer)Web Services?
- What is Unobtrusive JavaScript & Why it's Important?
- What Does JavaScript Void(0) Mean?
- What are JavaScript Cookies?
- Difference between Client side JavaScript and Server side JavaScript
- TypeError: document.getelementbyid(...) is null
- Uncaught TypeError: Cannot read property of undefined In JavaScript
- What's the difference between Null and Undefined?