Category: JavaScript OOPs

  • JavaScript Abstraction

    An abstraction is a way of hiding the implementation details and showing only the functionality to the users. In other words, it ignores the irrelevant details and shows only the required one. Points to remember JavaScript Abstraction Example Example 1 Let’s check whether we can create an instance of Abstract class or not. Example 2…

  • JavaScript Polymorphism

    The polymorphism is a core concept of an object-oriented paradigm that provides a way to perform a single action in different forms. It provides an ability to call the same method on different JavaScript objects. As JavaScript is not a type-safe language, we can pass any type of data members with the methods. JavaScript Polymorphism…

  • JavaScript Inheritance

    The JavaScript inheritance is a mechanism that allows us to create new classes on the basis of already existing classes. It provides flexibility to the child class to reuse the methods and variables of a parent class. The JavaScript extends keyword is used to create a child class on the basis of a parent class. It facilitates…

  • JavaScript Encapsulation

    The JavaScript Encapsulation is a process of binding the data (i.e. variables) with the functions acting on that data. It allows us to control the data and validate it. To achieve an encapsulation in JavaScript: – The encapsulation allows us to handle an object using the following properties: Read/Write – Here, we use setter methods to…

  • JavaScript static Method

    The JavaScript provides static methods that belong to the class instead of an instance of that class. So, an instance is not required to call the static method. These methods are called directly on the class itself. Points to remember JavaScript static Method Example 1 Let’s see a simple example of a static method. Output:…

  • JavaScript Constructor Method

    A JavaScript constructor method is a special type of method which is used to initialize and create an object. It is called when memory is allocated for an object. Points to remember Constructor Method Example Let’s see a simple example of a constructor method. Test it Now Output: 101 Martin Roy Constructor Method Example: super…

  • JavaScript Prototype Object

    JavaScript is a prototype-based language that facilitates the objects to acquire properties and features from one another. Here, each object contains a prototype object. In JavaScript, whenever a function is created the prototype property is added to that function automatically. This property is a prototype object that holds a constructor property. Syntax: What is the…

  • JavaScript Objects

    A javaScript object is an entity having state and behavior (properties and method). For example: car, pen, bike, chair, glass, keyboard, monitor etc. JavaScript is an object-based language. Everything is an object in JavaScript. JavaScript is template based not class based. Here, we don’t create class to get the object. But, we direct create objects.…

  • JavaScript Classes

    In JavaScript, classes are the special type of functions. We can define the class just like function declarations and function expressions. The JavaScript class contains various class members within a body including methods or constructor. The class is executed in strict mode. So, the code containing the silent error or mistake throws an error. The…