Lodash Cheatsheet - Utility Functions
This reference is for JS devs who would rather use a well-tested helper than reimplement the same loop by hand. Entries span arrays, objects, strings, collections, and function utilities, with each command showing the exact call that solves a stubborn problem — like reading a deeply nested value that may not exist, deep-cloning to avoid mutating shared state, or debouncing an input handler. Unlike native methods, Lodash versions handle nullish inputs and edge cases for you. After reading you should be able to pick the right helper for dedupe, grouping, debounce, and safe deep merge.
Array 7
_.map(arr, (n) => n * 2)_.filter(arr, (n) => n > 0)_.reduce(arr, (sum, n) => sum + n, 0)_.chunk(arr, 2)_.flattenDeep([1, [2, [3]]])_.uniq([1, 2, 1, 3])_.union([1, 2], [2, 3])Object 7
_.get(obj, "a.b.c", "default")_.set(obj, "a.b.c", value)_.pick(obj, ["name", "age"])_.omit(obj, ["password"])_.merge(target, source)_.cloneDeep(obj)_.keys(obj) / _.values(obj)String 6
_.camelCase("Foo Bar")_.kebabCase("FooBar")_.template("<%= name %>")({ name: "Vue" })_.escape("<a>")_.trim(" abc ")_.pad("abc", 8)Collection 6
_.groupBy(users, "age")_.sortBy(users, ["age", "name"])_.countBy([1, 2, 2, 3], Math.floor)_.keyBy(users, "id")_.sampleSize(arr, 2)_.shuffle(arr)Function 6
_.debounce(fn, 300)_.throttle(fn, 300)_.memoize(fn)_.once(fn)_.partial(fn, _, 2)_.bind(fn, thisArg, arg1)Number & Math 5
_.random(0, 100)_.range(0, 5)_.clamp(num, 0, 100)_.inRange(num, 0, 100)_.round(1.234, 2)Utility & Type 7
_.isEmpty(value)_.isEqual(a, b)_.isNil(value)_.isArray(value) / _.isObject(value)_.has(obj, "a.b")_.defaults({ a: 1 }, { a: 0, b: 2 })_.noop()Tips
- lodash-es is the ESM build with tree-shaking for smaller bundles.
- _.get/_.set safely handle deeply nested objects without undefined errors.
- Use debounce for search inputs, throttle for scroll/resize.
- Modern JS can replace some Lodash with natives like flat() and Object.keys().
- Import a single method (e.g. lodash/cloneDeep) to shrink the bundle further.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us