HTML Preparation code:
x
 
1
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
2
<script src=''>
3
4
</script>
Script Preparation code:
 
var omit1 = (originalObj = {}, keysToOmit = []) =>
    Object.fromEntries(
        Object.entries(originalObj)
        .filter(([key]) => !keysToOmit.includes(key))
    )
var omit2 = new Function('obj', 'if (!obj) return {}; const { a, d, i, ...res } = obj; return res;');
var omit3 = (originalObject = {}, keysToOmit = []) => {  
    const clonedObject = { ...originalObject };              
    for (const path of keysToOmit) {                
      delete clonedObject[path]       
    }           
    return clonedObject;
}
function omit4(obj, keys) {
  var target = {};
  for (var i in obj) {
    if (keys.indexOf(i) >= 0) continue;
    if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
    target[i] = obj[i];
  }
  return target;
}
function omitProd(src) {
    if (!src || typeof src !== 'object') return {};
    const clonedObject = { ...src };
    let idx = 0;
    let propsList = arguments;
    if (Array.isArray(propsList[1])) {
        propsList = propsList[1];
        idx = -1;
    }
    const len = propsList.length;
    while (++idx < len) {
        const key = propsList[idx];
        delete clonedObject[key];
    }
    return clonedObject;
}
function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
}
var data = [];
for (let i = 0; i < 10000; i++) {
    const obj = {};
    const propsCount = getRandomInt(0, 10);
  
    for (let j = 0; j < propsCount; j++) {
        
        const propCode = getRandomInt(97, 122);
      
        obj[String.fromCharCode(propCode)] = propCode;
    }
  
    data.push(obj);
}
Tests:
  • Lodash

     
    data.map((obj) => _.omit(obj, ['a','d','i']))
  • es omit

     
    data.map((obj) => omit1(obj, ['a','d','i']))
  • compiled omit

     
    data.map((obj) => omit2(obj, ['a','d','i']))
  • rest and delete omit

     
    data.map((obj) => omit3(obj, ['a','d','i']))
  • babel

     
    data.map((obj) => omit4(obj, ['a','d','i']))
  • dest and rest

     
    data.map((obj) => { const { a, d, i, ...rest } = obj; return rest; })
  • prod version

     
    data.map((obj) => omitProd(obj, 'a','d','i'))
  • prod version array

     
    data.map((obj) => omitProd(obj, ['a','d','i']))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Lodash
    es omit
    compiled omit
    rest and delete omit
    babel
    dest and rest
    prod version
    prod version array

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Chrome 93 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Lodash 41.1 Ops/sec
es omit 144.9 Ops/sec
compiled omit 89.5 Ops/sec
rest and delete omit 198.7 Ops/sec
babel 118.2 Ops/sec
dest and rest 96.2 Ops/sec
prod version 145.2 Ops/sec
prod version array 141.5 Ops/sec