Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js unique string array

const uniqueStrArr = (value, index, self) => {
  return self.indexOf(value) === index;
}

// usage example:
var arr = ['a', 1, 'a', 2, '1'];
var unique = arr.filter(uniqueStrArr);

console.log(unique); // ['a', 1, 2, '1']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #unique #string #array
ADD COMMENT
Topic
Name
4+3 =