const arr = [10, 20, 30, 40, 50];
const first_item = _.head(arr);
// => 10
In the code snippet, we have defined an array arr and we want to get the very first element of this array. We have used lodash method head() for this purpose which is returning 10 as the result.
_.head(Array)
Array: [Required] The array whose first element you want to get.
0 Comments