Get colon time from a JavaScript date
Get the time part of a Date object in the format HH:MM:SS.
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.
Get the time part of a Date object in the format HH:MM:SS.
Ever wanted to iterate over nested iterables in JavaScript? Here's how.
Generate an array, containing the Fibonacci sequence, up until the nth term, using two different approaches.
Learn how you can compare two dates in JavaScript, determining which one comes before or after the other.
Learn how to convert between Map
s and objects in JavaScript.
Here's a quick tip on how to compare and sort arrays of strings, ignoring case and accents.
Learn how to quickly write code to sort JavaScript arrays with this handy one-liner.
Learn how to calculate the angle (theta) between two vectors in JavaScript.
Understanding the differences between synchronous and asynchronous code is a crucial piece of knowledge for every web developer.
Regular expressions are a very useful tool. Save this cheatsheet for when you need to look up their syntax and speed up your development.
Randomness and pure functions don't seem to go hand in hand. But where there's a will, there's a way.
Learn how to generate a random hexadecimal color code with a few lines of JavaScript.
Property enumerability dictates how JavaScript object properties behave in different scenarios.
Learn how to convert an asynchronous function to return a promise in JavaScript.
Naming conventions make code easier to read and understand. Learn how to name your variables in JavaScript with this handy guide.
Calculate the midpoint between two pairs of points in a 2D plane, and beyond.
Determine if the current JavaScript environment is Node.js or a browser.
Want to know if a string is an absolute URL? This snippet will help you out.
JavaScript provides two methods for encoding characters to URL-safe strings. Do you know when to use each one?
Check if an iterable is a superset of another one, excluding duplicate values.
If you need to replace all occurrences of a string in JavaScript, you have a couple of options.
A JavaScript promise's then
and finally
methods seem very similar. But there are a few important differences you need to keep in mind.
Scroll listeners can easily become a performance bottleneck for your web application. Here's how to fix that.
When working with objects, you'll often need to check if a value or key exists, and these snippets will show you how to do just that.