79127240

Date: 2024-10-25 20:31:48
Score: 0.5
Natty:
Report link

New variants:

Fastest must be this:

var set = new Set( [ 1,2,3 ] ); 
console.log( set[Symbol.iterator]().next().value );

Short variant:

var set = new Set( [ 1,2,3 ] ); 
console.log( set.values().find( () => true ) );

// OR

console.log( set.values().find( () => 1 ) );

About last one: set.values() return Iterator, then I use Iterator.prototype.find

MDN article https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/find

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: Rustam