JavaScript code snippets and lessons

Skillthrive is a community for anyone that wants to learn how to code with JavaScript.

Join 12.4k members on our mailing list to stay updated about the latest content and community news at Skillthrive.

Join our growing community

53.8k

YouTube subscribers

12.4k

Newsletter subscribers

Latest lessons

Bit-sized video tutorials and written explainations.

hunter
Hunter Becton

May 25, 2022

If your page loads and you see a broken image, it can be pretty jarring and prevent users from exploring your content. The fix is simple: include an image that is a placeholder for the broken image, so nothing falls apart when it doesn't load. This post will describe one way to do this in React ...

Next.js

React

hunter
Hunter Becton

April 23, 2022

Hooking up your navigation bar to respond to user interaction is a great way to improve the user experience. For example, when the user scrolls down, you can add a slight shadow to the top of the navigation to make it look like it's lying on the page. In this lesson, you'll use a custom React h ...

JavaScript

hunter
Hunter Becton

March 24, 2022

A lot of JavaScript developers reach for a library like date-fns when working with dates in JavaScript. Although a library like date-fns provides a lot of functionality, you may not even need it. For example, you can use the built-in JavaScript Date method toLocaleString() to format a timestamp...

JavaScript

hunter
Hunter Becton

September 9, 2021

I'm working on a new project called Mattermix that enables users to create graphic design assets from HTML and CSS using a browser-based editor and API. The browser-based editor needs enough space to write HTML and CSS, create data form fields, and see the rendered code. That's a lot to fit on...

React

Latest snippets

Handy code snippets you can copy and paste.

Fallback image component

Replace broken image links with a placeholder with Next.js image.

Next.js

React

Filter object for allowed keys

Remove unwanted keys and values from a JavaScript object.

JavaScript

Abbreviate number

Shorten a number like 34,000 to 34K.

JavaScript

Combine CSS classes

Combine CSS classes for easy dynamic styling.

JavaScript

CSS