VOOZH about

URL: https://www.geeksforgeeks.org/javascript/collect-js-forpage-function/

⇱ Collect.js | forPage() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collect.js | forPage() Function

Last Updated : 15 Jul, 2025

The forPage() function is used to return the value which is present at a particular page, this function take the page number as an argument and then returns the collection. In JavaScript, the array is first converted to a collection and then the function is applied to the collection.


Syntax: 

data.forPage(x,y)

Parameters: This function accept two parameter as mentioned above and described below :

  • x: This parameter holds the page number.
  • y: This parameter holds the number of items to show per page.

Return Value:  Returns a new collection.
 

Below examples illustrate the forPage() function in collect.js
Example 1: Here in this example, we take a collection and then using the forPage() function we display the value from the page given as argument, and return the value

Output:

[ 6, 7, 8, 9 ]

Example 2:

Output:

[ 7, 8 ]

Reference: https://collect.js.org/api/forpage

Comment
Article Tags: