

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to redundantly remove duplicate elements within an array – JavaScript?
Let’s say the following are our array elements −
10,20,10,50,60,10,20,40,50
To remove duplicate elements, use … new Set().
Example
Following is the code −
var arrayWithNoDuplicateNumbers = [...new Set([10,20,10,50,60,10,20,40,50])]; console.log("No Duplicate values=") console.log(arrayWithNoDuplicateNumbers);
To run the above program, use the following command −
node fileName.js.
Here, my file name is demo243.js.
Output
The output is as follows −
PS C:\Users\Amit\javascript-code> node demo243.js No Duplicate values= [ 10, 20, 50, 60, 40 ]
- Related Questions & Answers
- How to remove duplicate elements from an array in JavaScript?
- How to remove duplicate elements of an array in java?
- How do I recursively remove consecutive duplicate elements from an array?
- How to duplicate elements of an array in the same array with JavaScript?
- Using recursion to remove consecutive duplicate entries from an array - JavaScript
- How to remove certain number elements from an array in JavaScript
- How to remove duplicate property values in array – JavaScript?
- Remove/ filter duplicate records from array - JavaScript?
- Using recursion to remove consecutive duplicate entries from an array in JavaScript
- How to remove blank (undefined) elements from JavaScript array - JavaScript
- Remove duplicate items from an array with a custom function in JavaScript
- Java program to remove the duplicate element in an array
- Sum identical elements within one array in JavaScript
- Removing duplicate elements from an array in PHP
- How do I make an array with unique elements (remove duplicates) - JavaScript?
Advertisements