Maps and Sets
Set From Array
Remove duplicates, then keep the values that match a rule.
Set From Array
set_from_array.js
const minLength = 3;
const tags = Array.from(new Set(["js", "web", "js", "trace"]))
.filter((tag) => tag.length >= minLength)
.join(",");
console.log("minLength=" + minLength);
console.log("tags=" + tags);
set-from-array
`Array.from(new Set(values))` is a compact way to remove duplicates while preserving first-seen order. After that, normal array methods can continue the pipeline.