Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash vs Just
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Browser:
Chrome 125
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash get
2440359.2 Ops/sec
Just get
1209240.1 Ops/sec
Lodash set
1089164.9 Ops/sec
Just set
830402.8 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
Script Preparation code:
var person = {name: 'Frederick', lastName: 'Corcino Alejo', nested: {name: 'test'}}; function justGet(obj, propsArg, defaultValue) { if (!obj) { return defaultValue; } var props, prop; if (Array.isArray(propsArg)) { props = propsArg.slice(0); } if (typeof propsArg == 'string') { props = propsArg.split('.'); } if (typeof propsArg == 'symbol') { props = [propsArg]; } if (!Array.isArray(props)) { throw new Error('props arg must be an array, a string or a symbol'); } while (props.length) { prop = props.shift(); if (!obj) { return defaultValue; } obj = obj[prop]; if (obj === undefined) { return defaultValue; } } return obj; } function justSet(obj, propsArg, value) { var props, lastProp; if (Array.isArray(propsArg)) { props = propsArg.slice(0); } if (typeof propsArg == 'string') { props = propsArg.split('.'); } if (typeof propsArg == 'symbol') { props = [propsArg]; } if (!Array.isArray(props)) { throw new Error('props arg must be an array, a string or a symbol'); } lastProp = props.pop(); if (!lastProp) { return false; } prototypeCheck(lastProp); var thisProp; while ((thisProp = props.shift())) { prototypeCheck(thisProp); if (typeof obj[thisProp] == 'undefined') { obj[thisProp] = {}; } obj = obj[thisProp]; if (!obj || typeof obj != 'object') { return false; } } obj[lastProp] = value; return true; } function prototypeCheck(prop) { // coercion is intentional to catch prop values like `['__proto__']` if (prop == '__proto__' || prop == 'constructor' || prop == 'prototype') { throw new Error('setting of prototype values not supported'); } }
Tests:
Lodash get
_.get(person, 'name', ''); _.get(person, 'nested.name', '');
Just get
justGet(person, 'name', ''); justGet(person, 'nested.name', '');
Lodash set
_.set(person, 'nested.name.test', 'test'); _.set(person, 'name', 'test'); _.set(person, 'nested.name', 'test');
Just set
justSet(person, 'nested.name.test', 'test'); justSet(person, 'name', 'test'); justSet(person, 'nested.name', 'test');