Answers for "how to get unique values from array js"

5

how to find unique elements in array in javascript

let a = ["1", "1", "2", "3", "3", "1"];
let unique = a.filter((item, i, ar) => ar.indexOf(item) === i);
console.log(unique);
Posted by: Guest on May-17-2020
15

javascript get unique values from array

const myArray = [1,2,3,1,5,8,1,2,9,4];
const unique = [...new Set(myArray)]; // [1, 2, 3, 5, 8, 9, 4]

const myString = ["a","b","c","a","d","b"];
const uniqueString = [...new Set(myString)]; //["a", "b", "c", "d"]
Posted by: Guest on July-25-2020
1

find unique values between multiple array

var array3 = array1.filter(function(obj) { return array2.indexOf(obj) == -1; });
Posted by: Guest on May-01-2020

Code answers related to "how to get unique values from array js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language