How to calculate date difference in JavaScript
Learn how to calculate date difference in seconds, minutes, hours, days etc. in vanilla JavaScript.
30 seconds of code contains a curated collection of code articles covering a wide range of development needs. The collection spans many topics, ranging from simple coding problems to theoretical concepts and development techniques.
Learn how to calculate date difference in seconds, minutes, hours, days etc. in vanilla JavaScript.
Quickly find the minimum or maximum date in an array of dates.
Learn how you can compare two dates in JavaScript, determining which one comes before or after the other.
Easily calculate the date of yesterday, today or tomorrow in JavaScript.
Quickly and easily determine if a given JavaScript Date object is a weekday or weekend.
Easily remove duplicates from a JavaScript array using the built-in Set object, and learn a few other tricks along the way.
Learn how you can implement a delay function using setTimeout(), promises and async/await.
Learn how to manipulate Date objects to add minutes, hours, days and more.
Determine the day, week, month, or quarter of the year that a date corresponds to, using vanilla JavaScript.
Learn how JavaScript handles mutable data, such as objects and arrays, and understand how shallow cloning and deep cloning work.
Number-only inputs aren't as straightforward as you might expect. Here's a user-friendly way to set them up.
Learn how to manipulate JavaScript objects by flattening or unflattening them.
Calculate the logarithm of a number or check if a number is a power of a specific base.
Learn how to compact an array or object in JavaScript using the Boolean function and recursion.
Given a sorted array, find the correct index to insert a given value.
Explore how you can apply mathematical set operations to JavaScript Set objects and arrays.
Check if an iterable is a superset of another one, excluding duplicate values.
A complete guide to case conversion in JavaScript, including camel case, kebab case, snake case, Pascal case, title case and sentence case.
String splitting and truncation, both simple and locale-sensitive are possible in JavaScript. Learn how in this guide.
Test if a string's start or end partially matches another string.
When working with JavaScript arrays, you might need the minimum or maximum value. Here are a few quick and easy ways to do it.
A short introduction to the functional programming paradigm.
Function arity is a simple, yet useful concept in functional programming, especially when combined with currying.
Currying is a process that transforms a function that takes multiple arguments into a series of functions that each take a single argument.