HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Tests:
  • lodash set

     
    const a = {b:{q: "QWe", w:"ert",e:"ert",r:"ret",t:"rty",y:"werw",u:"ytu",i:"reh",o:"eeh",p:"Weas"}};
    _.set(a,".b.c", "what");
  • spread

     
    const a = {b:{q: "QWe", w:"ert",e:"ert",r:"ret",t:"rty",y:"werw",u:"ytu",i:"reh",o:"eeh",p:"Weas"}};
    a.b = { ...a.b, c: "what" };
  • just if

     
    const a = {b:{q: "QWe", w:"ert",e:"ert",r:"ret",t:"rty",y:"werw",u:"ytu",i:"reh",o:"eeh",p:"Weas"}};
    if(a.b){
      a.b.c = "what";
    }else{
      a.b = {c: "what"};
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash set
    spread
    just if

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Linux; Android 10; CLT-L09) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Mobile Safari/537.36 OPR/64.2.3282.60128
Opera Mobile 64 on Android
View result in a separate tab
Test name Executions per second
lodash set 357879.9 Ops/sec
spread 186686.1 Ops/sec
just if 95600944.0 Ops/sec