JavaScript tips you won't see in most tutorials.

🧵
1. "Go back" button

Use the `history.back()` to create a “Go Back” button.
2. Numbers separators

To improve readability for numbers, you can use underscores as separators:
3. Run event listener only once

If you want to add an event listener but have it run only once, you can use the ` once` option:
4. You can wrap your console.log() arguments with curly brackets to see the variable names.
5. Get min/max value from an array

You can use `Math.min()` or `Math.max()` combined with the spread operator to find the minimum or maximum value in an array.
6. Copy to clipboard

You can use the `Clipboard` API to create the “Copy to clipboard” functionality:
If you liked this thread, maybe you'd love to bookmark it as a post.

P.S. You can find a few more tips there. https://markodenic.com/javascript-tips/
You can follow @denicmarko.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: