- 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 9291 Articles for Object Oriented Programming
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
341 Views
The optional catch binding introduced in ES2019 allows us to remove the surrounding parentheses of a catch binding i.e. we don’t need to use a variable to store the error object. It is useful especially if we know about the error in advance or even if want to react to an error without knowing about it.Following is the code for the optional catch binding 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)
380 Views
The String.trimStart() method is used to remove whitespace from the string beginning while the String.trimEnd() method removes whitespace from the end of the string.Following is the code for the String.trimStart() and String.trimEnd() methods −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result,.sample { font-size: 20px; font-weight: 500; } String.trimStart() and String.trimEnd() methods { resEle.innerHTML = "trimStart() :" + str.trimStart() + "|"; resEle.innerHTML += "trimEnd() :" + str.trimEnd() + "|"; }); OutputThe above code will produce the following output −On clicking the ‘CLICK HERE’ button −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
99 Views
The Object.fromEntries() method in JavaScript is used for converting an iterable like an array, map having a key value pair into an object.Following is the code for the Object.fromEntries() method −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result, .sample { font-size: 20px; font-weight: 500; } Object.fromEntries() method [[firstName, Rohan], [lastName, Sharma], [age, 22]] Object = CLICK HERE Click on the above button to convert the above array into object ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
67 Views
The JavaScript array.flatMap() function flattens the given nested array into a new flat array.Following is the code for the array.flatMap() method −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 20px; font-weight: 500; } JavaScript Array flatMap() CLICK HERE Click on the above button to convert the nested array to flat array let fillEle = document.querySelector(".sample"); let arr = ["cow", ["bull", "lion", "tiger"], "sheep"]; for ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
121 Views
The JavaScript Array.flat() method is used to flatten an array recursively up to a specified depth. It doesn’t manipulate the original array but creates a new flattened array.Following is the code for the Array.flat() method −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result, .sample { font-size: 20px; font-weight: 500; } Array.flat() method [1, 2, 3, [4, 5], [6, [7, 8]]] After flat : CLICK HERE Click on the above button to ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
122 Views
The JavaScript Array.protoype.includes() method is used to check if an array contains a given element or not.Following is the code for the Array.protoype.includes() method −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 20px; font-weight: 500; } JavaScript Array includes() CLICK HERE Click on the above button to check if the array contains lion element or not let fillEle = document.querySelector(".sample"); let arr = ["cow", "bull", "lion", "tiger", ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Const and let were introduced in ES2015 to declare block scoped variables. While variables declared using let can be reassigned, they cannot be reassigned if they were declared using const.Following is the code showing let and const in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result, .sample { font-size: 20px; font-weight: 500; } Const and let in JavaScript CLICK HERE Click on the above button to reassign const and let ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
139 Views
Following is the code to add, access JavaScript object methods −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 20px; font-weight: 500; } Add, Access JavaScript object methods CHECK Click on the above button to add and access object methods. let resEle = document.querySelector(".result"); let obj = { firstName:'Rohan', lastName: 'Sharma', Age:'22', } document.querySelector(".Btn").addEventListener("click", () => { ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
154 Views
To declare block scoped variables, we use the keyword let and const introduced in ES2015.Following is the code showing declaring black scoped variables in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result, .sample { font-size: 20px; font-weight: 500; } Declaring block scoped variables CLICK HERE Click on the above button to declare and display block scoped variables let resEle = document.querySelector(".result"); let sampleEle = document.querySelector(".sample");{ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
254 Views
Following is the code for removing elements using splice() method in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample,.result { font-size: 20px; font-weight: 500; } Remove elements using splice() CLICK HERE Click on the above button to remove elements between 1st and 5th element let fillEle = document.querySelector(".sample"); let resEle = document.querySelector(".result"); let arr = [1, 3, 5, 7, 9, 11]; fillEle.innerHTML = arr; document.querySelector(".Btn").addEventListener("click", () => { arr.splice(1, 4); resEle.innerHTML = "Spliced array = " + arr; }); OutputThe above code will produce the following output −On clicking the ‘CLICK HERE’ button −