HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
Script Preparation code:
 
var arr = [];
var object = { 
    type: 'aaa',
    subtype: 'bbb',
    card_last4:'bbb',
    card_type:'bbb',
    card_exp_month:'bbb',
    card_exp_year:'bbb',
    card_country:'bbb',
    foo: 'bar'
};
for (var i = 0; i <= 100000; i++) { arr.push(object); }
Tests:
  • Lodash

     
    arr.map(function (element) {
        return _.omit(
            element,
            'card_last4',
            'card_type',
        );
    });
  • Native

    x
     
    arr.map(function (element) {
        const {
          card_last4,
          card_type,
          ...rest
        } = element;
        return rest;
    });
  • Manual omit

     
    arr.map(function (element) {
        return {
          type: element.type,
          subtype: element.subtype,
          card_exp_month: element.card_exp_month,
          card_exp_year: element.card_exp_year,
          card_country: element.card_country,
          something: element.something
        };
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Lodash
    Native
    Manual omit

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.45 Safari/537.36
Chrome 99 on Linux
View result in a separate tab
Test name Executions per second
Lodash 4.6 Ops/sec
Native 10.2 Ops/sec
Manual omit 127.3 Ops/sec