Found 6710 Articles for Javascript

Dot notation vs Bracket notation in JavaScript

AmitDiwan
Updated on 20-Jul-2020 07:57:11

2K+ Views

The dot notation and bracket notation both are used to access the object properties in JavaScript. The dot notation is used mostly as it is easier to read and comprehend and also less verbose. The main difference between dot notation and bracket notation is that the bracket notation allows us to access object properties using variable.Following is the code for bracket notation vs dot notation in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;     ... Read More

Dot notation in JavaScript

AmitDiwan
Updated on 20-Jul-2020 07:54:04

2K+ Views

The dot notation is used to access the object properties in JavaScript. Following is the code to implement dot notation −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Dot notation in JavaScript. CLICK HERE Click on the above button to access the student1 object properties using dot notation    let resEle = document.querySelector(".result");    let BtnEle = document.querySelector(".Btn");    function ... Read More

RegExp object in JavaScript.

AmitDiwan
Updated on 20-Jul-2020 07:51:54

153 Views

The RegExp object is used for pattern matching some text by searching and extracting the part of text. The RegExp object can be created either using the regexp constructor or the literal syntax.Following is the code for RegExp object in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,    .sample {       font-size: 20px;       font-weight: 500;    } RegExp object CLICK HERE Click on the above button to test the regex expression ... Read More

How to check if an object is an instance of a Class in JavaScript?

AmitDiwan
Updated on 20-Jul-2020 07:49:06

419 Views

Following is the code to check if an object is an instance of a class in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Check if an object is an instance of a Class CLICK HERE Click on the above button to check if student1 object is an instance of Student    let resEle = document.querySelector(".result");    function Student(name, ... Read More

Static Properties in JavaScript

AmitDiwan
Updated on 20-Jul-2020 07:47:03

151 Views

Static properties are assigned to the class function itself and not to its prototype property. These properties can be called directly without instantiating any objects.Following is the code for static properties in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Static Properties in JavaScript CLICK HERE Click on the above button to the access the static property school of Student ... Read More

Share methods in JavaScript

AmitDiwan
Updated on 20-Jul-2020 07:45:25

641 Views

Methods can be shared by attaching them to the prototype property of the object. These methods will be shared among all the instances of the object.Following is the code for sharing methods in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Shared methods in JavaScript CLICK HERE Click on the above button to the call the displayInfo method of student1 ... Read More

Shared properties in JavaScript

AmitDiwan
Updated on 20-Jul-2020 07:41:09

394 Views

Properties can be shared by attaching them to the prototype property of the object. These properties will be shared among all the instances of the object.Following is the code for sharing properties in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Shared properties in JavaScript CLICK HERE Click on the above button to the view properties of student1 and student2 ... Read More

Passing a function as a callback in JavaScript

AmitDiwan
Updated on 20-Jul-2020 07:38:02

249 Views

Following is the code for passing a function as a callback in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Passing a function as a callback CLICK HERE Click on the above button to pass the add2() function as callback to multiply9() function    let resEle = document.querySelector(".result");    function add2(a) {       return a + 2;    }    function multiply9(fn, num) {       return fn(num) * 9;    }    document.querySelector(".Btn").addEventListener("click", () => {       resEle.innerHTML = "The number returned = " + multiply9(add2, 12);    }); OutputOn clicking the ‘CLICK HERE’ button −

Invoking functions with call() and apply() in JavaScript

AmitDiwan
Updated on 20-Jul-2020 07:36:10

176 Views

Following is the code for invoking functions with call() and apply() in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: blueviolet;    } Invoking functions with call() and apply() Click Here Click on the above buttons to invoke functions with call() and apply() method    let resEle = document.querySelector(".result");    let BtnEle = document.querySelector(".Btn");    function addNum(num1, num2, num3, num4) { ... Read More

Implementation of Queue in JavaScript

AmitDiwan
Updated on 20-Jul-2020 07:33:10

329 Views

Following is the code to implement queue in JavaScript.Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: blueviolet;    }    button {       padding: 6px;       margin: 4px;    } Implementation of queue in JavaScript. Enqueue Dequeue Display Click on the above buttons to perform queue operations    let resEle = document.querySelector(".result");    let BtnEle = ... Read More

Advertisements