Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Get object value by Path
(version: 0)
Comparing performance of:
Case 1 vs Case 2
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
Object.byString = function(o, s) { s = s.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties s = s.replace(/^\./, ''); // strip a leading dot var a = s.split('.'); for (var i = 0, n = a.length; i < n; ++i) { var k = a[i]; if (k in o) { o = o[k]; } else { return; } } return o; }
Tests:
Case 1
Object.byString({ a: 1 }, 'a');
Case 2
Object.byString({ a: 1 }, 'a');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Case 1
Case 2
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Get object value by path vs lodash get
Lodash.get vs object-path vs Property dot notation
Lodash.get vs object-path vs Property dot notation (optional chaining)
Lodash.get vs object-path vs Property dot notation vs Optional chaining
Comments
Confirm delete:
Do you really want to delete benchmark?