Convert an integer to a roman numeral in JavaScript
Roman numerals are often used for stylistic reasons, but converting an integer to a roman numeral can be a bit tricky.
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.
Roman numerals are often used for stylistic reasons, but converting an integer to a roman numeral can be a bit tricky.
Convert all the keys of an object to upper or lower case.
Ever wanted to get the value of an HTML input element as a number? Learn an easy way to do it with this handy trick.
Learn how to manipulate Date
objects to add minutes, hours, days and more.
Learn how you can compare two arrays in JavaScript using various different techniques.
Efficiently check if a numeric array is sorted in ascending or descending order in JavaScript.
Learn everything you need to know about Big-O notation with this handy cheatsheet.
Groups the elements of an array based on the given function.
Learn how to initialize a 2D array in JavaScript in a handful of different ways.
Creates a new MutationObserver
and runs the provided callback for each mutation on the specified element.
Use some clever JavaScript tricks to listen for and handle scroll stop events in the browser.
Remove an element from an array if it's included in the array, or push it to the array if it isn't.
Which method do you reach for first? What are the differences between them? Let's find out!
Learn how to change the lightness component of an hsl()
color string using JavaScript.
Easily create a debounced function that returns a promise.
Learn how to add an event listener that is executed at most once.
Learn how to transform objects by filtering their properties based on an array of keys or a predicate function.
Inverts the key-value pairs of an object, without mutating it.
Learn how to check if a number is prime and how to generate prime numbers up to a given number in JavaScript.
Learn how to write a JSON object to a file, both using Node.js and in the browser.
Learn how to create a string with uppercase characters converted to lowercase and vice versa.
Defers invoking a function until the current call stack has cleared.
Using the Proxy object, we can create dynamic getters and setters for objects in JavaScript.
Use JavaScript's Math.hypot()
to calculate the Euclidean distance between two points.