/ Published in: JavaScript

This code is used to get the unique values of an array.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
const array = [1, 1, 1, 3, 3, 2, 2]; var unique = array.filter((element, index) => { return array.indexOf(element) === index; }); //unique.toString(); for(var i=0;i<unique.length;i++){ console.log(unique[i]+"\r\n<br>"); }
Comments
