Test loop array (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
FILTER
let data = [
  {
    id: 1,
    value: 'one',
	selected: true
  }, {
    id: 2,
    value: 'two',
	selected: false
  }, {
    id: 3,
    value: 'three',
	selected: true
  }, {
    id: 4,
    value: 'four',
	selected: true
  }, {
    id: 5,
    value: 'five',
	selected: false
  },
];

const res = data.filter((item) => item.selected);
ready
LOOP
let data = [
  {
    id: 1,
    value: 'one',
	selected: true
  }, {
    id: 2,
    value: 'two',
	selected: false
  }, {
    id: 3,
    value: 'three',
	selected: true
  }, {
    id: 4,
    value: 'four',
	selected: true
  }, {
    id: 5,
    value: 'five',
	selected: false
  },
];

const res = [];
data.forEach((element) => {
  if (element.selected) {
	res.push(element);
  }
});

ready

Revisions

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