diff --git a/snippets/without.md b/snippets/without.md new file mode 100644 index 000000000..00876b5c9 --- /dev/null +++ b/snippets/without.md @@ -0,0 +1,12 @@ +### Without + +Use `Array.filter()` to create an array excluding all given values + +```js + +const without = (arr, ...args) => arr.filter(v => args.indexOf(v) === -1) + +// without[2, 1, 2, 3], 1, 2) -> [3] +// without([2, 1, 2, 3, 4, 5, 5, 5, 3, 2, 7, 7], 3, 1, 5, 2) -> [ 4, 7, 7 ] + +``` diff --git a/tag_database b/tag_database index b2535a484..937676886 100644 --- a/tag_database +++ b/tag_database @@ -85,3 +85,4 @@ UUID-generator:utility validate-email:utility validate-number:utility value-or-default:utility +without:array