Date range generator in JavaScript
Create a generator that generates all dates in a given range.
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.
Create a generator that generates all dates in a given range.
Learn how to use JavaScript ES6 generators to create a range generator that produces a sequence of numbers.
Learn how to convert an asynchronous function to return a promise in JavaScript.
Oftentimes you might need to add a timeout to a promise in JavaScript. Learn how to do this and more in this short guide.
Learn how to perform function composition for asynchronous functions.
Wrap a function call in a try...catch block to handle errors and return the result or the caught error object.
Create a function that ensures another function is called only once.
Defer the invocation of a function until the current call stack has been cleared.
Create a throttled function that only invokes the provided function at most once per the specified interval.
Learn how you can check if a valid date object can be created from the given values.
Ever wanted to run a function on each animation frame? This article shows you how to do it using Window.requestAnimationFrame().
Use the binary search algorithm to find the index of a given element in a sorted array.
Use the linear search algorithm to find the first index of a given element in an array.
Learn how to transpose a two-dimensional array in JavaScript.
Learn how to calculate the Hamming distance between two values.
Assign default values for all properties in an object that are undefined.
Calculate the number of ways to choose k items from n items without repetition and without order.
Learn how to get the currently selected text in the browser using JavaScript.
Find the distance from a given element to the top of the document with this simple JavaScript function.
Ever had elements that horizontally overflow the viewport? This JavaScript function can help you identify them.
Group the elements of an array based on the given function, producing an object with the grouped values.
Level up your event handling skills by learning how to attach or detach event listeners from multiple elements at once.
Ever wanted to listen for multiple events on an element and handle them with the same function? Here's how!
Learn how you can compare two objects in JavaScript using various different techniques.