From e35b4e0bb36d1e45e1a659edd8ba1ce03418b146 Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Fri, 23 Jul 2021 16:08:32 +0300 Subject: [PATCH] Update hide.md --- snippets/hide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/hide.md b/snippets/hide.md index c4d1af1a8..fc9d6dd9b 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -7,12 +7,12 @@ lastUpdated: 2020-09-15T16:28:04+03:00 Hides all the elements specified. -- Use `NodeList.prototype.forEach()` to apply `display: none` to each element specified. +- Use the spread operator (`...`) and `Array.prototype.forEach()` to apply `display: none` to each element specified. ```js -const hide = nodes => nodes.forEach(e => (e.style.display = 'none')); +const hide = (...el) => [...el].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 ```