A RetroSearch Logo

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

Search Query:

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

Lodash _.identity() Method - GeeksforGeeks

Lodash _.identity() Method

Last Updated : 27 Oct, 2023

Lodash _.identity method returns the first argument it receives.

Syntax:
_.identity(value);
Parameters: Return Value:

Returns the first argument it receives.

Example 1: In this example, it is returning the first parameter because of the lodash _.identity() method.

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

// Use of _.identity() method   
let user = [
    { 'name': 'XXXX', 'age': 36, 'active': true },
    { 'name': 'YYYY', 'age': 40, 'active': false }
];

let gfg = _.identity(user);

// Printing the output  
console.log(gfg);

Output:

[Object {active: true, age: 36, name: "XXXX"}, Object {active: false, age: 40, name: "YYYY"}]

Example 2: In this example, it is returning true as the first parameter of the lodash _.identity() method returning the same element as it stored in a company variable.

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

// Use of _.identity() method   
let company = { 'name': 'geeksforgeeks' };

let gfg = _.identity(company) === company;

// Printing the output  
console.log(gfg);

Output:

true


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