JavaScript tips you won't see in most tutorials.

🧵
1. "Go back" button

Use the `history.back()` to create a “Go Back” button. <button onclick="history.back()">   Go back </butt
2. Numbers separators

To improve readability for numbers, you can use underscores as separators: const largeNumber = 1_000_000_000;  console.log(largeNumber)
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: element.addEventListener('click', () => console.log('I run o
4. You can wrap your console.log() arguments with curly brackets to see the variable names. const myNumber = 123; // Instead of doing this: // console.l
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. const numbers = [6, 8, 1, 3, 9];  console.log(Math.max(...nu
6. Copy to clipboard

You can use the `Clipboard` API to create the “Copy to clipboard” functionality: function copyToClipboard(text) {   navigator.clipboard.write
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.

markodenic.com/javascript-tip…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Marko ⚡ Denic

Marko ⚡ Denic Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @denicmarko

10 Apr
GitHub repositories to improve your programming skills.

🧵
1. Free Programming Books

Freely available programming books

182k ⭐

Repo: github.com/EbookFoundatio…
2. Coding Interview University

A complete computer science study plan to become a software engineer.

162k ⭐

Repo: github.com/jwasham/coding…
Read 18 tweets
5 Apr
HTML tips - hidden gems.

🧵
1. The `loading=lazy` attribute

You can use the `loading=lazy` attribute to defer the loading of the image until the user scrolls to them. <img src='image.jpg' loading='lazy' alt='Alternative Text'>
2. Email, call, and SMS links: <a href="mailto:{email}?subject={subject}&body={content
Read 15 tweets
2 Apr
CSS tips you won't see in most tutorials.

🧵
1. Smooth scrolling

Smooth scrolling with zero JavaScript, with just one line of CSS. html {   scroll-behavior: smooth; }
2. When you work with transparent images you can use the `drop-shadow()` filter function to create a shadow on the image's content, instead of `box-shadow` property which creates a rectangular shadow behind an element's entire box:

filter: drop-shadow(2px 4px 8px #585858); Two images shown. One with rectangular shadow around whole i
Read 15 tweets
29 Mar
Are you're learning JavaScript?

I'm sure you've heard a million times to learn the fundamentals first.

But what are they? And where to learn them?

I made a list of JavaScript fundamentals and free resources for learning them.

🧵
2. Data Types

Understanding data types, by @lisaironcutter.

digitalocean.com/community/tuto…
Read 11 tweets
28 Mar
Websites to find a remote job:

📌 flexjobs. com
📌 remote. co
📌 justremote. co
📌 weworkremotely. com
📌 remoteok. io
📌 jobspresso. co
📌 europeremotely. com
📌 wfh. io
📌 dailyremote. com
📌 angel. co
📌 jsremotely. com
📌 remoteleaf. com
📌 remoteleads. io
📌 hired. com
It looks like @gitlab has a lot of open positions.

Read 5 tweets
24 Mar
Websites to find code snippets.

🧵
1. CSS Tricks Snippets

~ HTML
~ CSS
~ Sass
~ SVG
~ htaccess
~ JavaScript
~ jQuery
~ WordPress
~ PHP

Link: css-tricks.com/snippets/
2. 30 Seconds Of Code

~ JavaScript
~ CSS
~ Python
~ React

Link: 30secondsofcode.org
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!