diff --git a/README.md b/README.md
index b63604cce..44f3bf9b4 100644
--- a/README.md
+++ b/README.md
@@ -3679,17 +3679,17 @@ hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then
Hides all the elements specified.
-Use the spread operator (`...`) and `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 = (...el) => [...el].forEach(e => (e.style.display = 'none'));
+const hide = els => els.forEach(e => (e.style.display = 'none'));
```
Examples
```js
-hide(...document.querySelectorAll('img')); // Hides all elements on the page
+hide(document.querySelectorAll('img')); // Hides all
elements on the page
```
hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393' -
Hides all the elements specified.
Use the spread operator (...) and Array.forEach() to apply display: none to each element specified.
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); -
hide(...document.querySelectorAll('img')); // Hides all <img> elements on the page +
Hides all the elements specified.
Use NodeList.prototype.forEach() to apply display: none to each element specified.
const hide = els => els.forEach(e => (e.style.display = 'none')); +
hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history.
Use location.protocol to get the protocol currently being used. If it's not HTTPS, use location.replace() to replace the existing page with the HTTPS version of the page. Use location.href to get the full address, split it with String.split() and remove the protocol part of the URL.
const httpsRedirect = () => { if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); }; diff --git a/snippets/hide.md b/snippets/hide.md index 3c396cec4..16d40cf0f 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -5,7 +5,7 @@ Hides all the elements specified. Use `NodeList.prototype.forEach()` to apply `display: none` to each element specified. ```js -const hide = els => els.forEach(e => e.style.display = 'none'); +const hide = els => els.forEach(e => (e.style.display = 'none')); ``` ```js