HTML Preparation code:
AخA
 
1
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js"></script>
Script Preparation code:
x
 
data = {
    abf: 'asd',
    message: 'koko',
   _id: '{{objectId()}}',
    index: '{{index()}}',
    guid: '{{guid()}}',
    isActive: '{{bool()}}',
    balance: '{{floating(1000, 4000, 2, "$0,0.00")}}',
    picture: 'http://placehold.it/32x32',
    age: '{{integer(20, 40)}}',
    eyeColor: '{{random("blue", "brown", "green")}}',
    name: '{{firstName()}} {{surname()}}',
    gender: '{{gender()}}',
    company: '{{company().toUpperCase()}}',
    email: '{{email()}}',
    phone: '+1 {{phone()}}',
    address: '{{integer(100, 999)}} {{street()}}, {{city()}}, {{state()}}, {{integer(100, 10000)}}',
    about: '{{lorem(1, "paragraphs")}}',
    registered: '{{date(new Date(2014, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss Z")}}',
    latitude: '{{floating(-90.000001, 90)}}',
    longitude: '{{floating(-180.000001, 180)}}'
}
keysToOmit = ['longitude', 'gender', 'guid', 'abf']
Tests:
  • Native delete

     
     Object.keys(data).forEach((key) => {
       keysToOmit.includes(key) && delete data[key];
    });
    return { 
      data
    }
  • Lodash omit

     
    return { 
      data: _.omit(data, keysToOmit)
    }
  • ES6 Destructure

     
    var {longitude, gender, guid, abf, ...rest} = data
    return { 
      data: rest
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Native delete
    Lodash omit
    ES6 Destructure

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15
Safari 13 on Mac OS X 10.15.4
View result in a separate tab
Test name Executions per second
Native delete 341682.9 Ops/sec
Lodash omit 276979.1 Ops/sec
ES6 Destructure 338724.3 Ops/sec