JavaScript Polymorphism

Javascript is based on the OOPs Concept, i.e., Javascript is an object-oriented programming language that uses classes and objects for computations. Polymorphism is the OOPs principle which provides the facility to perform one task in many ways. Sub-class object calls the parent class method example: <!DOCTYPE html> <html> <body> <script> class Welcome { show() { … Read more

JavaScript static Method

Static methods in JavaScript is a way for providing class level methods. To declare a static method, we have to use static keyword as prefix with method name. Syntax: class className(){ static methodName(){ //method body } } Ways to call static methods 1. Using Class name ClassName.methodName(); 2. On the constructor property of the class … Read more

JavaScript Constructor Method

To initialize and create an object in Javascript, a constructor method is used which is called when memory is allocated for an object. A class in Javascript can contain one constructor method only, however, a parent class constructor can be used by using the super keyword. Example: <!DOCTYPE html> <html> <body> <script> class Student { … Read more

JavaScript Class

According to Wikipedia: In object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods). A class in Javascript is a special type of function that contains various class members including methods or constructors. A class in JavaScript can be … Read more

JavaScript email validation

JavaScript email validation: An email is tricky because of its format. Some of the basic checks are as follows: Presence of @ and . character Presence of at least one character before and after the @. Presence of at least two characters after. (dot). Example <!DOCTYPE html> <html lang=”en”> <head> <script> function validateEmail(emailId) { var … Read more