From 54e71191fcec908a8c32b980c17ba252c3deada4 Mon Sep 17 00:00:00 2001 From: King Date: Fri, 15 Dec 2017 02:35:30 -0500 Subject: [PATCH] add without.md --- snippets/without.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 snippets/without.md 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 ] + +```