From e35cb76b666c75ab0dbf723e6bbd3d574563ab69 Mon Sep 17 00:00:00 2001 From: Siarhei Date: Wed, 29 Aug 2018 13:50:25 +0400 Subject: [PATCH 1/2] Simplify hide --- snippets/hide.md | 4 ++-- test/hide/hide.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/hide.md b/snippets/hide.md index a80888583..24b1ed544 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -2,10 +2,10 @@ Hides all the elements specified. -Use the spread operator (`...`) and `Array.forEach()` to apply `display: none` to each element specified. +Use `Array.forEach()` to apply `display: none` to each element specified. ```js -const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); +const hide = els => els.forEach(e => e.style.display = 'none'); ``` ```js diff --git a/test/hide/hide.js b/test/hide/hide.js index 0d4044db0..21099679b 100644 --- a/test/hide/hide.js +++ b/test/hide/hide.js @@ -1,2 +1,2 @@ -const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); +const hide = els => els.forEach(e => e.style.display = 'none'); module.exports = hide; From d217716ccce6f186b17bf1e4f6986f6d6f4dc6db Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Wed, 29 Aug 2018 23:08:11 +0200 Subject: [PATCH 2/2] Update hide.md --- snippets/hide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/hide.md b/snippets/hide.md index 24b1ed544..3c396cec4 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -2,12 +2,12 @@ Hides all the elements specified. -Use `Array.forEach()` to apply `display: none` to each element specified. +Use `NodeList.prototype.forEach()` to apply `display: none` to each element specified. ```js const hide = els => els.forEach(e => e.style.display = 'none'); ``` ```js -hide(...document.querySelectorAll('img')); // Hides all elements on the page +hide(document.querySelectorAll('img')); // Hides all elements on the page ```