# InnerJoin

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

## Usage

#### Install

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

#### Import

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

#### Usage

Example Data

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

const data2 = [
  {
    id: 1,
    firstName: "John"
  },
  {
    id: 2,
    firstName: "Mike"
  }
];
```

Syntax

```javascript
innerJoin(data, data2, "userId", "id");

// innerJoin([data, [otherData, [dataField, [otherDataField]]]])
```

Output

```javascript
[
  {
    id: 1,
    userId: 1,
    title: "delectus aut autem",
    firstName: "John"
  },
  {
    id: 2,
    userId: 2,
    title: "quis ut nam facilis et officia qui",
    firstName: "Mike"
  }
];
```

{% hint style="danger" %}
&#x20;If two arrays have the same fields, the fields of the second given array are used.
{% endhint %}
