What's your favorite JavaScript single LOC (line of code)

By Nguyen Huu Phuoc

Check if all items in an array are equal#

Check if an object is an array#

Convert an array of strings to numbers#

Create an array of cumulative sum#

Create an array of numbers in the given range#

Find the maximum item of an array#

Find the minimum item of an array#

Get a random item from an array#

Get the average of an array#

Get the sum of array of numbers#

Get the unique values of an array#

Check if an element is a descendant of another#

Check if an element is focused#

Check if the touch events are supported#

Get all siblings of an element#

Go back to the previous page#

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#

Scroll to top of the page#

Strip html from a given text#

Check if a value is a number#

Check if an object is empty#

Convert rgb color to hex#

Create an empty function#

Create an empty map that does not have properties#

Generate a random hex color#

Get the value of a param from an url#

Check if a given integer is a prime number#

Check if a number is a power of 2#

Compute the greatest common divisor between two numbers#

Convert a string to number#

Generate a random number in given range#

Prefix an integer with zeros#

Check if a string contains whitespace#

Check if a string is lower case#

Check if a string is upper case#

Generate a random string from given characters#

Generate a random string with given length#

Get the file extension from a file name#

Get the file name from an url#

Replace all line breaks with br elements#