BubikolRamios wrote: ↑Sat Mar 03, 2018 9:38 pm
Is there predefined object in OO basic that is defined as array of unique values, so that, like :
array.add ("a") --> "a" added
array.add ("a") --> nothing added
I expect array will be huge, rolling thru it to check each time adding, if elemet is already in, would be a pain ....
some require writing code, some use simple arrays and some use methods provided by the JavaScript language. A
unique value in an array JavaScript is a value that appears exactly once. If you have an array with three integers, a unique value would be one of those three integers.
javascript find unique values in the array
Code: Select all
// usage example:
var myArray = ['a', 1, 'a', 2, '1'];
var unique = myArray.filter((v, i, a) => a.indexOf(v) === i);
// unique is ['a', 1, 2, '1']