How do I empty an array in JavaScript?
You can use a lot of different techniques to empty an array in JavaScript. See which ones best suits your needs with this quick guide.
The JavaScript snippet collection contains a wide variety of ES6 helper functions. It includes helpers for dealing with primitives, arrays and objects, as well as algorithms, DOM manipulation functions and Node.js utilities.
You can use a lot of different techniques to empty an array in JavaScript. See which ones best suits your needs with this quick guide.
Calculate the date of n
days ago from today or the date of n
days from now.
If you want to create an element from a string without appending it to the document, you can use a few lines of JavaScript.
CORS (Cross-Origin Resource Sharing) trips up many developers, but it's pretty easy to wrap your head around.
Use special Unicode characters to print text in color in the console.
JavaScript variables can be declared a handful of ways. However, understanding their differences can drastically change the way you code.
Learn how to transpose a two-dimensional array in JavaScript.
Learn how to easily convert any string to a URL-friendly slug, using regular expressions.
Here's a quick and easy way to select the currently focused DOM element in JavaScript.
Ever wanted to delete a property from a JavaScript object? Here are a few way you can accomplish that.
Did you know that implementing a non-mutating version of Array.prototype.splice()
is only a few lines of code?
Learn how to quickly remove an element from the DOM using JavaScript.
Learn everything you need to know about JavaScript modules with this handy cheatsheet.
Use the Date
object and some clever tricks to get the first or last date of a month in JavaScript.
Convert tabs to spaces, allowing you to control the number of spaces each tab corresponds to.
Learn how to check if an element is visible in the browser's viewport, using this simple technique.
Learn a simple way to get the browser's current URL in JavaScript.
JavaScript’s spread operator is a very versatile tool. Here are some simple ways to use it.
Learn how to create a promise that resolves after a given amount of time in JavaScript.
Recursion is a very important programming concept all developers should be familiar with.
Messing up the order of chained then
and catch
methods in JavaScript promises can cause problems. Here's a short primer on the subject.
Having a hard time wrapping your head around the math involved in checking for leap years? You might not need to!
Learn how to retrieve the first or last n
elements in a JavaScript array with a single line of code.
Learn how to create a directory using Node.js, if it doesn't exist.