javascript

Remove Duplicate Values From an Array in JavaScript Using ES6

We can easily get the distinct values in our JavaScript array by using the spread operator.

const arr = [1,1,4,5,5,37,57,28,67,67];
console.warn(arr); // [1,1,4,5,5,37,57,28,67,67]

//With Spread operator
const newArr = [...(new Set(arr)];
console.warn(newArr); //[1,  4,  5, 37, 57, 28, 67]

The spread operator makes it for us to iterate over an array and return distinct values.

7 JavaScript Shortcuts You Should Start Using

Recent Posts

Costly Linux Mistakes Beginners Make

1. Running Everything as Root One of the biggest beginner errors. Many new users log…

1 day ago

How Keyloggers Work

A keylogger is a type of surveillance software or hardware that records every keystroke made…

1 week ago

JavaScript Memoization

In JavaScript, it’s commonly used for: Recursive functions (like Fibonacci) Heavy calculations Repeated API/data processing…

1 month ago

CSS Container Queries: Responsive Design That Actually Makes Sense

For years, responsive design has depended almost entirely on media queries. We ask questions like: “If…

1 month ago

Cron Jobs & Task Scheduling

1. What is Task Scheduling? Task scheduling is the process of automatically running commands, scripts,…

1 month ago

Differences Between a Website and a Web App

Here’s a comprehensive, clear differentiation between a Website and a Web App, from purpose all the…

1 month ago