Socket
Socket
Sign inDemoInstall

lodash.identity

Package Overview
Dependencies
0
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.identity


Version published
Maintainers
4
Created

Package description

What is lodash.identity?

The lodash.identity package is a utility function that returns the first argument it receives. It is often used as a default iteratee or callback function in various lodash methods.

What are lodash.identity's main functionalities?

Basic Usage

The basic usage of lodash.identity is to return the first argument it receives. In this example, it simply returns the number 5.

const identity = require('lodash.identity');
console.log(identity(5)); // Output: 5

Using with Array Methods

Lodash.identity can be used as a callback function in array methods like map. In this example, it returns each element of the array as is.

const identity = require('lodash.identity');
const arr = [1, 2, 3, 4];
const result = arr.map(identity);
console.log(result); // Output: [1, 2, 3, 4]

Using with Lodash Methods

Lodash.identity can be used with other lodash methods like filter. In this example, it returns all elements of the array that are truthy.

const _ = require('lodash');
const identity = require('lodash.identity');
const arr = [1, 2, 3, 4];
const result = _.filter(arr, identity);
console.log(result); // Output: [1, 2, 3, 4]

Other packages similar to lodash.identity

Readme

Source

lodash.identity v2.1.0

The Lo-Dash function _.identity as a Node.js module generated by lodash-cli.

Dive in

There’s plenty of documentation, unit tests, & benchmarks.

Support

lodash.identity has been tested in at least Node.js 0.6.8-0.10.18.

Author

twitter/jdalton
John-David Dalton

Contributors

twitter/blainebublitztwitter/kitcambridgetwitter/mathias
Blaine BublitzKit CambridgeMathias Bynens

Keywords

FAQs

Last updated on 23 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc