array deconstruction (v2)

Revision 2 of this benchmark created on


Setup

const playerCount = 1234;
const players = Array.from({ length: playerCount }).fill(0).map((_, player_id) => ({ player_id }));

const a = Math.floor(Math.random() * playerCount);
const b = Math.floor(Math.random() * playerCount);

Test runner

Ready to run.

Testing in
TestOps/sec
in array
const [playerA, playerB] = [
  players.find(player => player.player_id === a),
  players.find(player => player.player_id === b),
];

playerA.player_id;
playerB.player_id;
ready
separate const
const playerA = players.find(player => player.player_id === a);
const playerB = players.find(player => player.player_id === b);

playerA.player_id;
playerB.player_id;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.