Lodash _.identity() Method
Lodash _.identity method returns the first argument it receives.
Syntax:
_.identity(value);
Parameters:
- value: It can be any value.
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
const _ = require( "lodash" );
let user = [
{ 'name' : 'XXXX' , 'age' : 36, 'active' : true },
{ 'name' : 'YYYY' , 'age' : 40, 'active' : false }
];
let gfg = _.identity(user);
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
const _ = require( "lodash" );
let company = { 'name' : 'geeksforgeeks' };
let gfg = _.identity(company) === company;
console.log(gfg);
|
Output:
true
Last Updated :
27 Oct, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...