30 seconds of code

Object

Click on a snippet card to view the snippet.

bindAll

Binds methods of an object to the object itself, overwriting the existing method.

deepClone

Creates a deep clone of an object.

deepFreeze

Deep freezes an object.

deepGet

Returns the target value in a nested JSON object, based on the keys array.

deepMapKeys

Deep maps an object's keys.

defaults

Assigns default values for all properties in an object that are undefined.

dig

Returns the target value in a nested JSON object, based on the given key.

equals

Performs a deep comparison between two values to determine if they are equivalent.

findKey

Returns the first key that satisfies the provided testing function. Otherwise undefined is returned.

findLastKey

Returns the last key that satisfies the provided testing function. Otherwise undefined is returned.

flattenObject

Flatten an object with the paths for keys.

forOwn

Iterates over all own properties of an object, running a callback for each one.

forOwnRight

Iterates over all own properties of an object in reverse, running a callback for each one.

functions

Returns an array of function property names from own (and optionally inherited) enumerable properties of an object.

get

Retrieve a set of properties indicated by the given selectors from an object.

invertKeyValues

Inverts the key-value pairs of an object, without mutating it. The corresponding inverted value of each inverted key is an array of keys responsible for generating the inverted value. If a function is supplied, it is applied to each inverted key.

lowercaseKeys

Creates a new object from the specified object, where all the keys are in lowercase.

mapKeys

Creates an object with keys generated by running the provided function for each key and the same values as the provided object.

mapValues

Creates an object with the same keys as the provided object and values generated by running the provided function for each value.

matches

Compares two objects to determine if the first one contains equivalent property values to the second one.

matchesWith

Compares two objects to determine if the first one contains equivalent property values to the second one, based on a provided function.

merge

Creates a new object from the combination of two or more objects.

nest

Given a flat array of objects linked to one another, it will nest them recursively. Useful for nesting comments, such as the ones on reddit.com.

objectFromPairs

Creates an object from the given key-value pairs.

objectToPairs

Creates an array of key-value pair arrays from an object.

omit

Omits the key-value pairs corresponding to the given keys from an object.

omitBy

Creates an object composed of the properties the given function returns falsy for. The function is invoked with two arguments: (value, key).

orderBy

Returns a sorted array of objects ordered by properties and orders.

pick

Picks the key-value pairs corresponding to the given keys from an object.

pickBy

Creates an object composed of the properties the given function returns truthy for. The function is invoked with two arguments: (value, key).

renameKeys

Replaces the names of multiple object keys with the values provided.

shallowClone

Creates a shallow clone of an object.

size

Get size of arrays, objects or strings.

transform

Applies a function against an accumulator and each key in the object (from left to right).

truthCheckCollection

Checks if the predicate (second argument) is truthy on all elements of a collection (first argument).

unflattenObject

Unflatten an object with the paths for keys.