Test name | Executions per second |
---|---|
for in with hasOwnProperty | 5392865.5 Ops/sec |
for of with Object.entries | 2356317.2 Ops/sec |
const props = { color: 'red', value: 'abc', fill: 'outline', button: true, redirect: 10, other: 'hello', object: { test: true }};
let result = {};
for (const prop in props) {
if (props.hasOwnProperty(prop)) {
result[prop] = props[prop];
}
}
const props = { color: 'red', value: 'abc', fill: 'outline', button: true, redirect: 10, other: 'hello', object: { test: true }};
let result = {};
for (const [prop, value] of Object.entries(props)) {
result[prop] = value;
}