205 Favorite JavaScript Utilities

in single line of code! No more!

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
#

Empty an array
#

Find the closest number from an array
#

Find the length of the longest string in an array
#

Find the maximum item of an array
#

Find the minimum item of an array
#

Flatten an array
#

Get the average of an array
#

Get the intersection of arrays
#

Get the sum of 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 falsy values from array
#

Shuffle an array
#

Sort an array of numbers
#

Split an array into chunks
#

Swap the rows and columns of a matrix
#

Unzip an array of arrays
#

Zip multiple arrays
#

DATE TIME

Calculate the number of difference days 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 timestamp in seconds
#

Get the day of the year from a date
#

Get the month name of a date
#

Get the number of days in given month
#

Get the tomorrow date
#

Get the weekday of a date
#

Get the yesterday date
#

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
#

Detect internet explorer browser
#

Detect macos browser
#

Get all siblings of an element
#

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
#

Show an element
#

Strip html from a given text
#

Toggle an element
#

FUNCTION

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 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
#

MISC

Check if the code is running in node js
#

Check if the code is running in the browser
#

Convert celsius to fahrenheit
#

Convert hex to rgb
#

Convert rgb color to hex
#

Decode a jwt token
#

Detect dark mode
#

Easing functions
#

Emulate a dice throw
#

Encode a url
#

Get the first defined and non null argument
#

Get the value of a param from an url
#

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 degrees to radians
#

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 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
#

Invert keys and values of an object
#

Omit a subset of properties from an object
#

Pick a subset of properties of an object
#

Shallow copy an object
#

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 string from given characters
#

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 from an array
#

STRING

Capitalize a string
#

Check if a path is relative
#

Check if a string is a palindrome
#

Check if a url is absolute
#

Check if two strings are anagram
#

Convert a string to camel case
#

Convert a string to pascal case
#

Convert a string to url slug
#

Convert a windows file path to unix path
#

Convert camel case to kebab case and vice versa
#

Convert snake case to camel case
#

Convert the name of an excel column to number
#

Escape html special characters
#

Get the base url without any parameters
#

Get the file extension from a file name
#

Get the file name from an url
#

Get the length of a string in bytes
#

Make the first character of a string lowercase
#

Normalize file path slashes
#

Remove spaces from a string
#

Repeat a string
#

Replace all line breaks with br elements
#

Replace multiple spaces with a single space
#

Replace the first given number of characters of a string with another character
#

Reverse a string
#

Sort the characters of a string in the alphabetical order
#

Strip ansi codes from 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 date is between two dates
#

Check if a date is today
#

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 lower case
#

Check if a string is upper case
#

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 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
#

Hit the Subscribe button for the latest news on my tools. No spam. Ever!
© 2020 Nguyen Huu Phuoc. All rights reserved