79222285

Date: 2024-11-25 08:55:41
Score: 0.5
Natty:
Report link

In terms of performance, using the spread operator is extremely slow in all but the simplest of cases.

Any other method seems fairly equal in terms of performance, both with small and large sets (benchmark here):

Result of different set accessors for first element benchmark

My favourite is definitely the restructuring assignment:

const [first] = set;

It's concise and reads well, and you can easily access the 2nd, 3rd, 4th elements as well.

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