A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/lodash-_-keys-method/ below:

Lodash _.keys() Method - GeeksforGeeks

Lodash _.keys() Method

Last Updated : 20 Oct, 2023

Lodash _.keys() method is used to return the list of all keys of the given object.

Syntax:
_.keys(object);
Parameters: Return Value:

This method returns the array of all keys of the given object.

Example 1: In this example, we are printing the keys of an object using the _.keys() method.

JavaScript
// Requiring the lodash library  
const _ = require("lodash");

// Given object
let obj = { 'a': 1, 'b': 2, 'c': 2 };

// Use of _.keys method 
console.log(_.keys(obj));

Output:

['a', 'b', 'c']

Example 2: In this example, we are printing the keys of an object using the _.keys() method.

JavaScript
// Requiring the lodash library  
const _ = require("lodash");

// Given object
let obj = {
    Name: "GeeksforGeeks",
    password: "gfg@1234",
    username: "your_geeks"
}

// Use of _.keys method 
console.log(_.keys(obj));

Output:

["Name", "password", "username"]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4