Skip to content

Object Helpers

Utility functions for working with object operations.

FunctionDescription
cloneCreates a shallow copy of a value — one level deep, unlike cloneDeep.
cloneDeepCreates a deep copy of an object or array.
compactRemoves all entries with falsy values (false, null, undefined, 0, "", NaN) from an object.
diffStructural object diff.
equalsDeepRecursive structural object equality.
equalsShallowOne-level (shallow) object equality.
flattenFlattens a nested object into a single-level object whose keys are the dot-notation path to each leaf value.
getGets a value from an object using a dot/bracket-notated path or explicit key array.
groupByGroups an array of items by a key derived from each item.
hasnative JS Object.hasOwn(obj, key) (ES2022)
invertReturns a new object with keys and values swapped.
isEmptyChecks if a plain object has no own enumerable string-keyed properties.
isNonEmptyChecks if a plain object has at least one own enumerable string-keyed property.
keys / valuesnative JS Object.keys() / Object.values() (ES2017)
mapTransforms the values and/or keys of a plain object in a single pass.
merge (shallow)native JS { ...a, ...b } or Object.assign({}, a, b) (ES2015)
mergeDeepMerges two or more objects deeply, returning a new object without mutating any input.
omitCreates a new object without the specified keys.
omitByCreates a new object without the own enumerable entries for which predicate returns true.
parsePropertyPathParses a dot/bracket-notation property path into an array of string/number key segments — the same notation accepted …
pickCreates a new object with only the specified keys.
pickByCreates a new object with only the own enumerable entries for which predicate returns true.
removeUndefinedNullRemove null and undefined values from an object.
safeJsonParseParses a JSON string, returning null (or a fallback) on any parse failure.
setSets a value in an object at the given path, creating intermediate objects as needed.
toPairs / fromPairsnative JS Object.entries() / Object.fromEntries() (ES2019)
unflattenRebuilds a nested object from a single-level object whose keys are dot-notation paths.
unsetRemoves the value at a dot/bracket-notation path or explicit key array, mutating the object in place.
updateUpdates the value at a path by applying a function to its current value, creating intermediate objects as needed.