bhylu.com

Advertisements

JS Set Reference

Converting between arrays and sets can remove duplicate primitive values while keeping their first insertion order.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const tags = ["wood", "fabric", "wood"];
console.log(Array.from(new Set(tags)));

What happens

The result is ["wood","fabric"].