Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Use Set to ensure the uniqueness of a list of values javascript

const array = Array
  .from(document.querySelectorAll('[id]'))
  .map(function(e) {
      return e.id
  });

const set = new Set(array);
console.assert(set.size == array.length);
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #Use #Set #ensure #uniqueness #list #values #javascript
ADD COMMENT
Topic
Name
3+5 =