Functions for working with objects and object properties. These utilities provide comprehensive object manipulation, property access, and iteration capabilities.
| Function | Description | Parameters | Returns |
|---|---|---|---|
keys |
Gets own enumerable keys | object |
Array of keys |
keysIn |
Gets own and inherited keys | object |
Array of keys |
values |
Gets own enumerable values | object |
Array of values |
valuesIn |
Gets own and inherited values | object |
Array of values |
entries |
Gets own enumerable entries | object |
Array of [key, value] pairs |
entriesIn |
Gets own and inherited entries | object |
Array of [key, value] pairs |
toPairs |
Converts to pairs | object |
Array of [key, value] pairs |
toPairsIn |
Converts to pairs (inherited) | object |
Array of [key, value] pairs |
assign |
Assigns properties | object, ...sources |
Modified object |
assignIn |
Assigns inherited properties | object, ...sources |
Modified object |
assignWith |
Assigns with customizer | object, ...sources, customizer |
Modified object |
assignInWith |
Assigns inherited with customizer | object, ...sources, customizer |
Modified object |
extend |
Alias for assignIn | object, ...sources |
Modified object |
extendWith |
Alias for assignInWith | object, ...sources, customizer |
Modified object |
defaults |
Assigns default properties | object, ...sources |
Modified object |
defaultsDeep |
Deep assigns default properties | object, ...sources |
Modified object |
get |
Gets property value | object, path, defaultValue? |
Property value |
set |
Sets property value | object, path, value |
Modified object |
setIn |
Sets nested property value | object, path, value |
Modified object |
setWith |
Sets with customizer | object, path, value, customizer |
Modified object |
update |
Updates property value | object, path, updater |
Modified object |
updateIn |
Updates nested property | object, path, updater |
Modified object |
updateWith |
Updates with customizer | object, path, updater, customizer |
Modified object |
unset |
Removes property | object, path |
Boolean (success) |
unsetIn |
Removes nested property | object, path |
Boolean (success) |
has |
Checks if property exists | object, path |
Boolean |
hasIn |
Checks if inherited property exists | object, path |
Boolean |
at |
Gets properties at paths | object, paths |
Array of values |
findKey |
Finds first key by predicate | object, predicate |
Key or undefined |
findLastKey |
Finds last key by predicate | object, predicate |
Key or undefined |
forIn |
Iterates over own and inherited properties | object, iteratee |
Object |
forInRight |
Iterates right to left | object, iteratee |
Object |
forOwn |
Iterates over own properties | object, iteratee |
Object |
forOwnRight |
Iterates over own properties (right to left) | object, iteratee |
Object |
functions |
Gets function property names | object |
Array of function names |
functionsIn |
Gets inherited function names | object |
Array of function names |
invert |
Inverts object keys and values | object |
New inverted object |
invertBy |
Inverts by iteratee | object, iteratee? |
New inverted object |
invoke |
Invokes method at path | object, path, ...args |
Method result |
mapKeys |
Maps object keys | object, iteratee |
New object with mapped keys |
mergeWith |
Merges with customizer | object, ...sources, customizer |
Merged object |
result |
Gets result of method/property | object, path, defaultValue? |
Method result or property value |
transform |
Transforms object | object, iteratee, accumulator? |
Accumulator |
Creates an array of the own enumerable property names of object.
import { keys } from 'highdash';
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
console.log(keys(new Foo()));
// => ['a', 'b'] (iteration order is not guaranteed)
console.log(keys({ 'a': 1, 'b': 2 }));
// => ['a', 'b']Creates an array of the own and inherited enumerable property names of object.
import { keysIn } from 'highdash';
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
console.log(keysIn(new Foo()));
// => ['a', 'b', 'c']Creates an array of the own enumerable string keyed property values of object.
import { values } from 'highdash';
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
console.log(values(new Foo()));
// => [1, 2]
console.log(values({ 'a': 1, 'b': 2 }));
// => [1, 2]Creates an array of the own and inherited enumerable string keyed property values of object.
import { valuesIn } from 'highdash';
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
console.log(valuesIn(new Foo()));
// => [1, 2, 3]Creates an array of the own enumerable string keyed property-value pairs for object.
import { entries } from 'highdash';
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
console.log(entries(new Foo()));
// => [['a', 1], ['b', 2]]
console.log(entries({ 'a': 1, 'b': 2 }));
// => [['a', 1], ['b', 2]]Creates an array of the own and inherited enumerable string keyed property-value pairs for object.
import { entriesIn } from 'highdash';
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
console.log(entriesIn(new Foo()));
// => [['a', 1], ['b', 2], ['c', 3]]Creates an array of the own enumerable string keyed property-value pairs for object.
import { toPairs } from 'highdash';
console.log(toPairs({ 'a': 1, 'b': 2 }));
// => [['a', 1], ['b', 2]]Creates an array of the own and inherited enumerable string keyed property-value pairs for object.
import { toPairsIn } from 'highdash';
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
console.log(toPairsIn(new Foo()));
// => [['a', 1], ['b', 2], ['c', 3]]Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.
import { get } from 'highdash';
const object = { 'a': [{ 'b': { 'c': 3 } }] };
console.log(get(object, 'a[0].b.c'));
// => 3
console.log(get(object, ['a', '0', 'b', 'c']));
// => 3
console.log(get(object, 'a.b.c', 'default'));
// => 'default'
// Simple property access
console.log(get(object, 'a'));
// => [{ 'b': { 'c': 3 } }]Sets the value at path of object. If a portion of path doesn't exist, it's created.
import { set } from 'highdash';
const object = { 'a': [{ 'b': { 'c': 3 } }] };
set(object, 'a[0].b.c', 4);
console.log(object.a[0].b.c);
// => 4
set(object, ['x', '0', 'y', 'z'], 5);
console.log(object.x[0].y.z);
// => 5
// Simple property setting
set(object, 'simple', 'value');
console.log(object.simple);
// => 'value'Sets the value at path of object (immutable version).
Sets the value at path of object using customizer to determine how values are assigned.
Updates the value at path of object using the result of updater.
import { update } from 'highdash';
const object = { 'a': [{ 'b': { 'c': 3 } }] };
update(object, 'a[0].b.c', n => n * n);
console.log(object.a[0].b.c);
// => 9Updates the value at path of object (immutable version).
Updates the value at path of object using customizer to determine how values are updated.
Removes the property at path of object.
import { unset } from 'highdash';
const object = { 'a': [{ 'b': { 'c': 3 } }] };
console.log(unset(object, 'a[0].b.c'));
// => true
console.log(object.a[0].b);
// => {}Removes the property at path of object (immutable version).
Checks if path is a direct property of object.
import { has } from 'highdash';
const object = { 'a': [{ 'b': { 'c': 3 } }] };
console.log(has(object, 'a'));
// => true
console.log(has(object, 'a[0].b.c'));
// => true
console.log(has(object, 'a[0].b.d'));
// => falseChecks if path is a direct or inherited property of object.
Creates an array of values corresponding to paths of object.
import { at } from 'highdash';
const object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
console.log(at(object, ['a[0].b.c', 'a[1]']));
// => [3, 4]Assigns own enumerable string keyed properties of source objects to the destination object.
import { assign } from 'highdash';
function Foo() {
this.a = 1;
}
function Bar() {
this.c = 3;
}
Foo.prototype.b = 2;
Bar.prototype.d = 4;
console.log(assign({ 'a': 0 }, new Foo(), new Bar()));
// => { 'a': 1, 'c': 3 }Assigns own and inherited enumerable string keyed properties of source objects to the destination object.
import { assignIn } from 'highdash';
function Foo() {
this.a = 1;
}
function Bar() {
this.c = 3;
}
Foo.prototype.b = 2;
Bar.prototype.d = 4;
console.log(assignIn({ 'a': 0 }, new Foo(), new Bar()));
// => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }Assigns own enumerable string keyed properties of source objects to the destination object using customizer.
Assigns own and inherited enumerable string keyed properties of source objects to the destination object using customizer.
Alias for assignIn.
Alias for assignInWith.
Assigns own enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to undefined.
import { defaults } from 'highdash';
console.log(defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }));
// => { 'a': 1, 'b': 2 }Recursively assigns own enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to undefined.
import { defaultsDeep } from 'highdash';
console.log(defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }));
// => { 'a': { 'b': 2, 'c': 3 } }Iterates over elements of collection, returning the first element predicate returns truthy for.
import { findKey } from 'highdash';
const users = {
'barney': { 'age': 36, 'active': true },
'fred': { 'age': 40, 'active': false },
'pebbles': { 'age': 1, 'active': true }
};
console.log(findKey(users, o => o.age < 40));
// => 'barney'
console.log(findKey(users, { 'age': 1, 'active': true }));
// => 'pebbles'
console.log(findKey(users, 'active'));
// => 'barney'Iterates over elements of collection, returning the last element predicate returns truthy for.
import { findLastKey } from 'highdash';
const users = {
'barney': { 'age': 36, 'active': true },
'fred': { 'age': 40, 'active': false },
'pebbles': { 'age': 1, 'active': true }
};
console.log(findLastKey(users, o => o.age < 40));
// => 'pebbles'Iterates over own and inherited enumerable string keyed properties of object invoking iteratee for each property.
import { forIn } from 'highdash';
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
forIn(new Foo(), (value, key) => {
console.log(key);
});
// => Logs 'a', 'b', then 'c' (iteration order is not guaranteed)Iterates over own and inherited enumerable string keyed properties of object invoking iteratee for each property in reverse order.
Iterates over own enumerable string keyed properties of object invoking iteratee for each property.
import { forOwn } from 'highdash';
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
forOwn(new Foo(), (value, key) => {
console.log(key);
});
// => Logs 'a', then 'b' (iteration order is not guaranteed)Iterates over own enumerable string keyed properties of object invoking iteratee for each property in reverse order.
Creates an array of function property names from own enumerable properties of object.
import { functions } from 'highdash';
function Foo() {
this.a = () => 'a';
this.b = () => 'b';
}
Foo.prototype.c = () => 'c';
console.log(functions(new Foo()));
// => ['a', 'b']Creates an array of function property names from own and inherited enumerable properties of object.
import { functionsIn } from 'highdash';
function Foo() {
this.a = () => 'a';
this.b = () => 'b';
}
Foo.prototype.c = () => 'c';
console.log(functionsIn(new Foo()));
// => ['a', 'b', 'c']Creates an object composed of the inverted keys and values of object.
import { invert } from 'highdash';
const object = { 'a': 1, 'b': 2, 'c': 1 };
console.log(invert(object));
// => { '1': 'c', '2': 'b' }Creates an object composed of the inverted keys and values of object using iteratee to transform the inverted value.
import { invertBy } from 'highdash';
const object = { 'a': 1, 'b': 2, 'c': 1 };
console.log(invertBy(object, value => `group${value}`));
// => { 'group1': ['a', 'c'], 'group2': ['b'] }Invokes the method at path of object.
import { invoke } from 'highdash';
const object = {
'a': [{ 'b': { 'c': [1, 2, 3, 4] } }]
};
console.log(invoke(object, 'a[0].b.c.slice', 1, 3));
// => [2, 3]Creates an object with the same values as object and keys generated by running each own enumerable string keyed property of object through iteratee.
import { mapKeys } from 'highdash';
console.log(mapKeys({ 'a': 1, 'b': 2 }, (value, key) => key.toUpperCase()));
// => { 'A': 1, 'B': 2 }Recursively merges own enumerable string keyed properties of source objects into the destination object using customizer.
Resolves the value of property at path of object.
import { result } from 'highdash';
const object = {
'a': [{ 'b': { 'c1': 3, 'c2': () => 4 } }]
};
console.log(result(object, 'a[0].b.c1'));
// => 3
console.log(result(object, 'a[0].b.c2'));
// => 4
console.log(result(object, 'a[0].b.c3', 'default'));
// => 'default'Transforms object to a new accumulator object which is the result of running each of its own enumerable string keyed properties through iteratee.
import { transform } from 'highdash';
console.log(transform([2, 3, 4], (result, n) => {
result.push(n *= n);
return n % 2 === 0;
}, []));
// => [4, 9]// Import specific functions
import { keys, values, get, set } from 'highdash';
// Import from specific module (better tree-shaking)
import { keys } from 'highdash/object/keys.js';
import { get } from 'highdash/object/get.js';
import { set } from 'highdash/object/set.js';
// Import all object functions
import * as object from 'highdash/object';values: 7.8× faster than Lodash - direct property iteration with native methods- Property access: Optimized for simple property access patterns
- Path resolution: Efficient path parsing and traversal
- Memory usage: Creates new objects for immutable operations
- Type safety: Full TypeScript support with proper type inference
Performance metrics based on Node.js 18+ benchmarks, averaged over 5 runs.
- Property access: Use
get,set,hasfor safe property manipulation - Object iteration: Use
keys,values,entriesfor object traversal - Object merging: Use
assign,defaultsfor object composition - Deep operations: Use
defaultsDeep,mergeWithfor complex merging - Property filtering: Use
findKey,functionsfor property discovery - Object transformation: Use
transform,mapKeysfor data restructuring