Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 812 Bytes

how-can-i-use-lodash-to-find-the-unique-key-of-a-javascript-object.md

File metadata and controls

35 lines (23 loc) · 812 Bytes

How can I use Lodash to find the unique key of a JavaScript object?

// plain

Lodash provides a useful method for finding the unique keys of a JavaScript object: _.keys(). This method takes an object as an argument and returns an array of the object's keys.

For example:

const object = {
  a: 1,
  b: 2,
  c: 3
};

const uniqueKeys = _.keys(object);

console.log(uniqueKeys);

Output example

[a, b, c]

The _.keys() method:

  • takes an object as an argument
  • returns an array of the object's keys

Helpful links

onelinerhub: How can I use Lodash to find the unique key of a JavaScript object?