Object Oriented Programming Articles

Page 35 of 588

How do we loop through array of arrays containing objects in JavaScript?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 580 Views

Following is the code to loop through array of arrays containing objects in JavaScript −Example Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    } Loop through array of arrays containing objects in JavaScript CLICK HERE Click the above button to loop throught the arrObj    let BtnEle = document.querySelector(".Btn");    let resEle = document.querySelector(".result");    let arrObj = [     ...

Read More

Implementation of Stack in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 504 Views

Following is the code to implement stack in JavaScript −Example 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 Stack in JavaScript. Push Pop Display Click on the above buttons to perform stack operations    let resEle = document.querySelector(".result");    let BtnEle = document.querySelector(".Btn");   ...

Read More

Shared properties in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 431 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 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 objects ...

Read More

Share methods in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 687 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 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 and ...

Read More

Static Properties in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 178 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 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

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

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 450 Views

Following is the code to check if an object is an instance of a class in JavaScript −Example 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, age, ...

Read More

Dot notation in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

The dot notation is used to access the object properties in JavaScript. Following is the code to implement dot notation −Example 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 Student(name, ...

Read More

Dot notation vs Bracket notation in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 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 Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       ...

Read More

Setting object members in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 142 Views

Following is the code to set object members in JavaScript −Example Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Setting object members CLICK HERE Click on the above button to set student object members and display them    let resEle = document.querySelector(".result");    let BtnEle = document.querySelector(".Btn");    let student = {};    BtnEle.addEventListener("click", () => {       student.name = "Rohan";       student.age = 22;       student.displayInfo = function () {          resEle.innerHTML = "Name = " + this.name + " : Age = " + this.age;       };       student.displayInfo();    }); OutputOn clicking the ‘CLICK HERE’ button −

Read More

How to set JavaScript object values dynamically?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 798 Views

Following is the code for setting JavaScript object values dynamically −Example Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Set Javascript object values dynamically CLICK HERE Click on the above button to set student object values dynamically    let resEle = document.querySelector(".result");    let BtnEle = document.querySelector(".Btn");    let student = {       name: "Rohan",       age: 22,       displayInfo() {          return "Name = " + this.name + " : Age = " + this.age + "";       },    };    BtnEle.addEventListener("click", () => {       resEle.innerHTML = student.displayInfo();       resEle.innerHTML += "After changing properties ";       student.name = "Shawn";       student.age = 19;       resEle.innerHTML += student.displayInfo();    }); OutputOn clicking the ‘CLICK HERE’ button −

Read More
Showing 341–350 of 5,878 articles
« Prev 1 33 34 35 36 37 588 Next »
Advertisements