lodash typescript 1

lodash typescript

// Installation
npm i --save lodash

// Types
npm i --save @types/lodash

// Usage
import { flatten, isEqual, last, omit, pick, pickBy, uniq } from 'lodash';
flatten([[1,2],[3,4]]) // [ 1, 2, 3, 4 ]
last([ 1, 2, 3, 4 ]) // 4
uniq([1,2,3,1,2,3,2]) // [ 1, 2, 3 ]

Here is what the above code is Doing:
1. Importing the flatten, isEqual, last, omit, pick, pickBy, and uniq functions from the lodash library.
2. Using the flatten function to flatten an array of arrays.
3. Using the last function to get the last element of an array.
4. Using the uniq function to remove duplicate elements from an array.

Similar Posts