---
description: Paginate method of array helpers
---

# $.array.paginate

#### Paginate the array

You may want to create a pagination or to split the data into many pages for your table, post or other components. Here you need to use paginate helper to show only entries by the page limit (I mean the limit of entries per page) and by the current page active, this method will produce a new array.

```
$.array.paginate(fromArray, pageActive, limitPerPage)

// Example:
const fromArray = [
  { id: 1, name: 'Hanbal Tedir', office: 'Jakarta', age: 30 },
  { id: 2, name: 'Dawoud Tedir', office: 'Medan', age: 27 },
  { id: 3, name: 'Harist Tedir', office: 'Sigli', age: 15 },
  { id: 4, name: 'Tedir Ghazali', office: 'Banda Aceh', age: 29 },
  { id: 5, name: 'Hanbal Usman', office: 'Langsa', age: 27 },
  { id: 6, name: 'Dawoud Usman', office: 'Pidie', age: 25 },
  { id: 7, name: 'Harist Usman', office: 'Samarinda', age: 18 },
  { id: 8, name: 'Ghazali Usman', office: 'Balikpapan', age: 45 },
  { id: 9, name: 'Bukhari Usman', office: 'Makassar', age: 44 },
  { id: 10, name: 'Boyhaki Usman', office: 'Jaya Pura', age: 35 },
  { id: 11, name: 'Zulkifli Usman', office: 'Manado', age: 56 },
  { id: 12, name: 'Teuku Usman', office: 'Ternate', age: 58 }
]
$.array.paginate(fromArray, 3, 5)
//=> [
// { id: 11, name: 'Zulkifli Usman', office: 'Manado', age: 56 },
// { id: 12, name: 'Teuku Usman', office: 'Ternate', age: 58 }
//]
```

#### Pagination numbers or items

Creating pagination with javascript from scratch might be a bit tricky to do, so I provide a pagination helper to just solve that problem, this pagination helper will render a new array with pagination numbers in it, by using this method you guys can build a complete pagination through iteration.

```
$.array.pagination(totalPages, pageActive, positionEllipsis)

// Example:
$.array.pagination(12, 5, 2)
//=> ['...', 3, 4, 5, 6, 7, '...']
```

#### Get total pages from array

Before creating a pagination, we need to know the total pages of data, items, entries or record from the array, this is why we provide a helper for just generating a number of total pages.

```
$.array.pages(fromArray, limitPerPage)

// Example:
$.array.pages(values, 5)
//=> 3
```

#### Showing the information of pagination and entries per page

You may want to get the information of the current entries from the current page, here we provide pageInfo and will return an object with properties such as the entries that start from the beginning of page in a number, that end to the last entries of that page in a number and the total entries in a number.&#x20;

```
$.array.pageInfo(fromArray, pageActive, limitPerPage)

// Example:
$.array.pageInfo(values, 3, 5)
//=> { from: 11, to: 12, of: 12 }
```
