Creating null-filled objects

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Using Object.fromEntries + map
const columnNames = ['a', 'b', c]
Object.fromEntries(
    columnNames.map((columnName) => [columnName, null])
);
ready
Using Array.reduce
const columnNames = ['a', 'b', c]
columnNames.reduce((carry, current) => {
	carry[current] = null
	return carry;
  }, {});
ready

Revisions

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