HTML Preparation code:
AخA
 
1
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
window.arr = [{
    key : 'pier',
    object : 'organization',
    path : 'customAttributes',
    fullPath : 'customAttributes.pier',
    dataType : 'string',
    label : 'label',
    filterable : false,
    searchable : true,
    sortable : true,
    writable : true,
    custom : true,
    archived : false
}, {
    key : 'batang-pier',
    object : 'organization',
    path : 'customAttributes',
    fullPath : 'customAttributes.pier',
    dataType : 'string',
    label : 'label',
    filterable : false,
    searchable : true,
    sortable : true,
    writable : true,
    custom : true,
    archived : true
}, {
    key : 'global-port',
    object : 'organization',
    path : 'customAttributes',
    fullPath : 'customAttributes.pier',
    dataType : 'string',
    label : 'label',
    filterable : false,
    searchable : true,
    sortable : true,
    writable : true,
    custom : true,
    archived : false
}]
Tests:
  • Lodash

    x
     
    var result = _.reduce(arr, function(result, attribute) {
        if (!attribute.archived) {
            result[attribute.key] = attribute;
        }
        return result;
    }, {})
    console.log(result)
  • Native

     
    var result = arr.reduce(function(result, attribute) {
        if (!attribute.archived) {
            result[attribute.key] = attribute;
        }
        return result;
    }, {});
    console.log(result)
  • For Loop

     
    const result = {};
    for (let i = 0; i < arr.length; i++) {
        const attribute = arr[i];
        if (!attribute.archived) {
            result[attribute.key] = attribute;
        }
    }
    console.log(result)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Lodash
    Native
    For Loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36
Chrome 80 on Mac OS X 10.15.3
View result in a separate tab
Test name Executions per second
Lodash 49538.4 Ops/sec
Native 50513.1 Ops/sec
For Loop 46276.4 Ops/sec