---
description: >-
  "Limit" is used to get a limited number of elements from a json data. Almost
  javascript works like slice() but it is much easier and clearer.
---

# Limit

[Github](https://github.com/aykutkardas/Json-Function) repository for your stars.

## Usage

#### Install

```bash
$ npm install json-function
```

#### Import

```javascript
import { limit } from 'json-function';
```

#### Usage

Example Data

```javascript
const data = [
  {
    id: 1,
    userId: 1,
    title: "quis ut nam facilis et officia qui"
  },
  {
    id: 2,
    userId: 1,
    title: "lorem ipsum"
  },
  {
    id: 3,
    userId: 2,
    title: "delectus aut autem"
  }
];
```

Only Limit Syntax

```javascript
limit(data, 2);
// limit([arr, [limit]])
```

Output

```javascript
[
  {
    id: 1,
    userId: 1,
    title: "quis ut nam facilis et officia qui"
  },
  {
    id: 2,
    userId: 1,
    title: "lorem ipsum"
  }
];
```

Limit and Start Syntax

```javascript
limit(data, 2, 1);
// limit([arr, [limit, [start]]])
```

Output

```javascript
[
  {
    id: 2,
    userId: 1,
    title: "lorem ipsum"
  },
  {
    id: 3,
    userId: 2,
    title: "delectus aut autem"
  }
];
```
