- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9297 Articles for Object Oriented Programming
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
143 Views
Following is the code for loading JavaScript modules dynamically −Note − You need to run a localhost server to run this example.Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 18px; font-weight: 500; } Loading JavaScript modules dynamically IMPORT Click on the above button to import module script.jsimport test from './sample.js'; document.querySelector('.Btn').addEventListener('click',()=>{ test(); })sample.jslet resultEle = document.querySelector(".result"); export default function testImport(){ resultEle.innerHTML = 'Module testImport has been imported'; }OutputOn clicking the ‘IMPORT’ button −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
452 Views
Keyed collections are data collections that are ordered by key not index. They are associative in nature. Map and set objects are keyed collections and are iterable in the order of insertion.Following is the code for keyed collections 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; } Keyed collections in JavaScript CLICK HERE Click on the above button to ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
Arrays are the indexed collection in JavaScript as they allow us to access an element using its index.Following is the code to implement indexed collections 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; } Indexed collections in JavaScript CLICK HERE Click on the above button to create and display the array let resEle = document.querySelector(".result"); let BtnEle = document.querySelector(".Btn"); BtnEle.addEventListener("click", () => { let arr = [1, 2, 3, 4, 5]; arr.forEach((item, index) => { resEle.innerHTML += `arr[${index}] = ${item} `; }); }); OutputOn clicking the ‘CLICK HERE’ button −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
There are three types of conditional statements in JavaScript −If statement − The if statement is used to execute code inside the if block only if the specific condition is met.If else statement − The If….Else statement is used to check only two conditions and execute different codes for each of them.If else if else statement − The if…else if…else statement is used for checking more than two conditions.Following is the code to implement conditional statements in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
119 Views
Following is the code for modifying prototypes 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; } Modifying prototypes in JavaScript CLICK HERE Click on the above button to see the original and modified prototype function let resEle = document.querySelector(".result"); let BtnEle = document.querySelector(".Btn"); function Person(name, age, occupation) { this.name = name; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
645 Views
Following is the code for setting JavaScript object values dynamically −Example Live Demo 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 −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
76 Views
Following is the code to set object members 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; } 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 −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
104 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