Thursday, September 4, 2025
HomeLanguagesJavascriptCollect.js skip() Method

Collect.js skip() Method

The skip() method is used to skip the given number of elements from collection and returns the remaining collection elements.

Syntax:

collect(array).skip(size)

Parameters: The collect() method takes one argument that is converted into the collection and then skip() method is applied on it. The skip() method holds the size (number of elements that you want to skip from collection) as parameter.

Return Value: This method returns the remaining collection elements.

Below example illustrate the skip() method in collect.js:

Example 1:

Javascript




const collect = require('collect.js');
  
const collection = collect(['Geeks', 
    'GFG', 'neveropen', 'Welcome']);
  
const skipped = collection.skip(2);
  
console.log(skipped.all());


Output:

[ 'neveropen', 'Welcome' ]

Example 2:

Javascript




const collect = require('collect.js');
  
let obj = [
    {
        name: 'Rahul',
        marks: 88
    },
    {
        name: 'Aditya',
        marks: 78
    },
    {
        name: 'Abhishek',
        marks: 87
    }
];
  
const collection = collect(obj);
  
const skipped = collection.skip(1);
  
console.log(skipped.all());


Output:

[ { name: 'Aditya', marks: 78 }, { name: 'Abhishek', marks: 87 } ]
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6628 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11858 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6716 POSTS0 COMMENTS