@bakkerjoeri/array-without

Returns an array without given items.

Usage no npm install needed!

<script type="module">
  import bakkerjoeriArrayWithout from 'https://cdn.skypack.dev/@bakkerjoeri/array-without';
</script>

README

array-without

Exclude one or more items from an array.

Installation

npm install @bakkerjoeri/array-without

Usage

import arrayWithout from '@bakkerjoeri/array-without';

const groceries = ['apple', 'potato', 'pear', 'cucumber', 'orange'];
const noCucumber = arrayWithout(groceries, 'cucumber'); // => ['apple', 'potato', 'pear', 'orange']
const onlyFruits = arrayWithout(groceries, 'potato', 'cucumber'); // => ['apple', 'pear', 'orange']

The function returns a new array without mutating the initial array.