Test case details

Preparation Code

var data = { ...Array.from(Array(10000).keys()) };

Test cases

Test #1

Object.fromEntries(Object.entries(data).filter((d) => d[1]));

Test #2

Object.entries(data).reduce( (acc, [key, value]) => value === undefined ? acc : { ...acc, [key]: value }, {} );

Test #3

const res={} Object.entries(data).forEach(([key, value])=>{ if(value){ res[key]=value } })

Test #4

const res = new Map(); Object.entries(data).forEach(([key, value]) => { if (value) { res.set(key, value); } });