# smb-js-array

> This package will help you to get the difference between two arrays of objects in JavaScript

Latest version **1.0.0** (published 2022-09-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install smb-js-array
pnpm add smb-js-array
yarn add smb-js-array
bun add smb-js-array
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-09-28 |
| First published | 2022-09-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mahmoud-Barry |
| Maintainers | mahmoudbarry |
| Keywords | array, object, javascript |

## Links

- npm: https://www.npmjs.com/package/smb-js-array
- Repository: https://github.com/Mahmoud-Barry/mb-js-array
- Homepage: https://github.com/Mahmoud-Barry/mb-js-array#readme
- Issues: https://github.com/Mahmoud-Barry/mb-js-array/issues
- npm.io page: https://npm.io/package/smb-js-array

## Recent versions

- 1.0.0 (latest) — 2022-09-28

## README

# mb-js-array  
This package will help you to get the difference between two arrays of objects in JavaScript. 

## Installation
```
npm i mb-js-array

```
### Get the difference between two arrays of objects

```
the function takes three arguments

```
| Parameter | Description  |
| :-------- |:--------- |
| `param1`  | **Required**. the first array |
| `param2`  | **Required**. the second array |
| `param3`  | **Required**. the key to compare |

#### Example

```js
const diffArray = require('mb-js-array')

const arrayOne = [ 
    { id: 1, firstName: "Mahmoud", lastName:"Barry" },
    { id: 2, firstName: "Ben" ,lastName:"Barry" },
    { id: 3, firstName: "Demba" ,lastName:"Barry" },
  ];
  
  const arrayTwo = [
    { id: 1, firstName: "Mahmoud",lastName:"Barry" },
    { id: 2, firstName: "Sultan",lastName:"Ndiaye" },

  ];

// compare by id 
const byId = diffArray(arrayOne, arrayTwo,key="id")
console.log(byId) // [ { id: 3, firstName: 'Demba', lastName: 'Barry' } ]

// compare by lastName
const bylastName = diffArray(arrayOne, arrayTwo,key="lastName")
console.log(bylastName) // [ { id: 2, firstName: 'Sultan', lastName: 'Ndiaye' } ]

/* if no item the function will return */`no item`
```

---
_Source: https://npm.io/package/smb-js-array · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
