diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37b9cc767..15aab603c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,8 @@ Here's what you can do to help: - `i` for indexes. - `func` for function arguments. - `nums` for arrays of numbers. -- Use `_` if your function takes no arguments or if an argument inside some function (e.g. `Array.reduce()`) is not used anywhere in your code. +- Use `()` if your function takes no arguments. +- Use `_` if an argument inside some function (e.g. `Array.reduce()`) is not used anywhere in your code. - Specify default parameters for arguments, if necessary. It is preferred to put default parameters last unless you have pretty good reason not to. - If your snippet's function takes variadic arguments, use `..args` (although in certain cases, it might be needed to use a different name). - If your snippet function's body is a single statement, omit the `return` keyword and use an expression instead. diff --git a/snippets/UUID-generator.md b/snippets/UUID-generator.md index 01d4e27ac..342fce12b 100644 --- a/snippets/UUID-generator.md +++ b/snippets/UUID-generator.md @@ -3,7 +3,7 @@ Use `crypto` API to generate a UUID, compliant with [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) version 4. ```js -const uuid = _ => +const uuid = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) ); diff --git a/snippets/bottom-visible.md b/snippets/bottom-visible.md index b94ac773a..797b0eb00 100644 --- a/snippets/bottom-visible.md +++ b/snippets/bottom-visible.md @@ -3,7 +3,7 @@ Use `scrollY`, `scrollHeight` and `clientHeight` to determine if the bottom of the page is visible. ```js -const bottomVisible = _ => +const bottomVisible = () => document.documentElement.clientHeight + window.scrollY >= document.documentElement.scrollHeight || document.documentElement.clientHeight; // bottomVisible() -> true ``` diff --git a/snippets/current-URL.md b/snippets/current-URL.md index 200cf150b..3a549d219 100644 --- a/snippets/current-URL.md +++ b/snippets/current-URL.md @@ -3,6 +3,6 @@ Use `window.location.href` to get current URL. ```js -const currentUrl = _ => window.location.href; +const currentUrl = () => window.location.href; // currentUrl() -> 'https://google.com' ``` diff --git a/snippets/scroll-to-top.md b/snippets/scroll-to-top.md index 6c82190a4..19064a5d5 100644 --- a/snippets/scroll-to-top.md +++ b/snippets/scroll-to-top.md @@ -4,7 +4,7 @@ Get distance from top using `document.documentElement.scrollTop` or `document.bo Scroll by a fraction of the distance from top. Use `window.requestAnimationFrame()` to animate the scrolling. ```js -const scrollToTop = _ => { +const scrollToTop = () => { const c = document.documentElement.scrollTop || document.body.scrollTop; if (c > 0) { window.requestAnimationFrame(scrollToTop);