Last Updated : 02 Sep, 2024
The _.tail() method is used to create a new array that doesn't contain the first element of the original array.
Syntax:_.tail(array);Parameters:
Example 1: In this example, we are getting the tail of the array by the use of the lodash _.tail() method.
javascript
const _ = require('lodash');
let x = [1, 2, 3, 4, 5, 6, 7]
let newArray = _.tail(x);
console.log(newArray);
Output:
[ 2, 3, 4, 5, 6, 7 ]
Example 2: In this example, we are getting the tail of the array by the use of the lodash _.tail() method.
javascript
const _ = require('lodash');
let x = [
{ 'name': 'lodash' },
{ 'name': 'npm' },
{ 'name': 'nodejs' }
]
let newArray = _.tail(x);
console.log(newArray);
Output:
[ { name: 'npm' }, { name: 'nodejs' } ]
Note: This will not work in normal JavaScript because it requires the library lodash to be installed.
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