Favorite JavaScript Utilities

in single line of code! No more!

Array

Cast a value as an array
Check if an array is empty
Clone an array
Compare two arrays regardless of order
Compare two arrays
Convert an array of objects to a single object
Convert an array of strings to numbers
Count by the properties of an array of objects
Count the occurrences of a value in an array
Count the occurrences of array elements
Create an array of cumulative sum
Create an array of numbers in the given range
Create cartesian product
Empty an array
Find the closest number from an array
Find the index of the last matching item of an array
Find the index of the maximum item of an array
Find the index of the minimum item of an array
Find the length of the longest string in an array
Find the maximum item of an array by given key
Find the maximum item of an array
Find the minimum item of an array by given key
Find the minimum item of an array
Flatten an array
Generate an array of alphabet characters
Get all arrays of consecutive elements
Get all n-th items of an array
Get all subsets of an array
Get indices of a value in an array
Get the average of an array
Get the intersection of arrays
Get the rank of an array of numbers
Get the sum of an array of numbers
Get the unique values of an array
Get union of arrays
Group an array of objects by a key
Merge two arrays
Partition an array based on a condition
Remove duplicate values in an array
Remove falsy values from array
Repeat an array
Shuffle an array
Sort an array of items by given key
Sort an array of numbers
Split an array into chunks
Swap the rows and columns of a matrix
Swap two array items
Unzip an array of arrays
Zip multiple arrays

Date Time

Add AM PM suffix to an hour
Calculate the number of difference days between two dates
Calculate the number of months between two dates
Compare two dates
Convert a date to YYYY-MM-DD format
Convert seconds to hh:mm:ss format
Extract year, month, day, hour, minute, second and millisecond from a date
Format a date for the given locale
Get the current quarter of a date
Get the current timestamp in seconds
Get the day of the year from a date
Get the first date in the month of a date
Get the last date in the month of a date
Get the month name of a date
Get the number of days in given month
Get the timezone string
Get the tomorrow date
Get the total number of days in a year
Get the weekday of a date
Get the yesterday date
Initialize the current date but set time to midnight
Sort an array of dates

DOM

Check if an element is a descendant of another
Check if an element is focused
Check if the touch events are supported
Check if user scrolls to the bottom of the page
Detect Internet Explorer browser
Detect macOS browser
Get all siblings of an element
Get the position of an element relative to the document
Get the selected text
Go back to the previous page
Hide an element
Insert an element after other one
Insert an element before other one
Insert given HTML after an element
Insert given HTML before an element
Redirect to another page
Reload the current page
Replace an element
Scroll to top of the page
Serialize form data
Show an element
Strip HTML from a given text
Toggle an element

Function

Box handler
Check if a value is a function
Check if a value is a generator function
Check if a value is an async function
Compose functions from left to right
Compose functions
Create a function that accepts a single argument
Create an empty function
Curry a function
Delay the evaluation of a function
Execute a function once
Flip the arguments of a function
Identity function
Logical xor operator
Memoize a function
Partially apply a function
Uncurry a function

Math

Calculate the angle of a line defined by two points
Calculate the distance between two points
Calculate the linear interpolation between two numbers
Calculate the midpoint between two points
Check if a point is inside a rectangle
Check if a rectangle contains other one
Check if a rectangle overlaps other one
Convert degrees to radians
Convert radians to degrees
Normalize the ratio of a number in a range
Round a number to the nearest multiple of a given value

Misc

Check if the code is running in NodeJS
Check if the code is running in the browser
Clear all cookies
Convert 3 digits color to 6 digits color
Convert Celsius to Fahrenheit
Convert cookie to object
Convert Fahrenheit to Celsius
Convert hex to rgb
Convert rgb color to hex
Convert URL parameters to object
Decode a JWT token
Detect dark mode
Easing functions
Emulate a dice throw
Encode a URL
Generate an unique and increment id
Get the first defined and non null argument
Get the value of a cookie
Get the value of a param from a URL
Get type of a variable in string
Redirect the page to HTTPS if it is in HTTP
Run Promises in sequence
Swap two variables
Wait for an amount of time

Number

Add an ordinal suffix to a number
Calculate Fibonacci numbers
Calculate the average of arguments
Calculate the division of arguments
Calculate the factorial of a number
Calculate the mod of collection index
Calculate the remainder of division of arguments
Calculate the sum of arguments
Clamp a number between two values
Compute the greatest common divisor between two numbers
Convert a number to equivalent characters
Convert a string to number
Convert decimal to binary recursively
Get the arrays of digits from a number
Multiply arguments
Prefix an integer with zeros
Round a number to a given number of digits
Subtract arguments
Truncate a number at decimal
Truncate a number to a given number of decimal places without rounding

Object

Check if multiple objects are equal
Create an empty map that does not have properties
Create an object from the pairs of key and value
Extract values of a property from an array of objects
Get the value at given path of an object
Immutably rename object keys
Invert keys and values of an object
Omit a subset of properties from an object
Pick a subset of properties of an object
Remove all null and undefined properties from an object
Shallow copy an object
Sort an object by its properties

Random

Generate a random boolean
Generate a random floating point number in given range
Generate a random hex color
Generate a random integer in given range
Generate a random IP address
Generate a random sign
Generate a random string from given characters
Generate a random string using Node crypto module
Generate a random string with given length
Generate a random UUID
Generate an array of random integers in a given range
Get a random item and remove it from an array
Get a random item from an array
Get random items of an array
Pick a random property of an object
Pick random lines from a text document

String

Capitalize a string
Check if a path is relative
Check if a string consists of a repeated character sequence
Check if a string is a palindrome
Check if a URL is absolute
Check if two strings are anagram
Convert a letter to associate emoji
Convert a string to camelCase
Convert a string to PascalCase
Convert a string to URL slug
Convert a Windows file path to Unix path
Convert camelCase to kebab-case and vice versa
Convert snake_case to camelCase
Convert the name of an Excel column to number
Count the number of words in a string
Count the occurrences of a character in a string
Decapitalize a string
Escape HTML special characters
Generate a hash of a string
Get the base URL without any parameters
Get the file extension from a file name
Get the file name from a URL
Get the length of a string in bytes
Get the number of a character in a string
Make the first character of a string lowercase
Normalize file path slashes
Prepend a line number to each line of a text document
Remove duplicate lines of a text document
Remove empty lines of a text document
Remove spaces from a string
Repeat a string
Replace all line breaks with br elements
Replace all tab characters with spaces
Replace multiple spaces with a single space
Replace the first given number of characters of a string with another character
Reverse a string
Reverse the order of lines of a text
Sort lines of a text document in the alphabetical order
Sort the characters of a string in the alphabetical order
Strip ANSI codes from a string
Swap case of characters in a string
Trim slashes at the beginning and the end of a string
Trim some character
Trim the file extension from a file name
Truncate a string at full words
Unescape HTML special characters
Uppercase the first character of each word in a string

Validator

Check if a character is a digit
Check if a date is a weekday
Check if a date is a weekend
Check if a date is between two dates
Check if a date is today
Check if a date occurs in the current year
Check if a flat array has duplicate values
Check if a given integer is a prime number
Check if a number is a power of 2
Check if a number is even
Check if a number is in a given range
Check if a number is negative
Check if a number is odd
Check if a number is positive
Check if a string contains lower case characters
Check if a string contains only ASCII characters
Check if a string contains only digits
Check if a string contains only letters and numbers
Check if a string contains only letters
Check if a string contains upper case characters
Check if a string contains whitespace
Check if a string is a hexadecimal color
Check if a string is a hexadecimal number
Check if a string is a MongoDB ObjectId
Check if a string is an octal number
Check if a string is lower case
Check if a string is upper case
Check if a value is a business identifier code
Check if a value is a number
Check if a value is a plain object
Check if a value is a regular expression
Check if a value is a string
Check if a value is an object
Check if a value is base32 encoded
Check if a value is base58 encoded
Check if a value is base64 encoded
Check if a value is nil
Check if a year is leap year
Check if all array elements are equal to a given value
Check if all items in an array are equal
Check if an array contains a value matching some criterias
Check if an array is not empty
Check if an array is subset of other array
Check if an object is a Promise
Check if an object is an array
Check if an object is empty
Validate a Gregorian date