JavaScript Snippets
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.
Adds a class to an HTML element.
Adds the provided styles to the given element.
Checks if the provided predicate function returns
true
for all elements in a collection.Checks if all elements in an array are equal.
Checks if all elements in an array are unique.
Checks if the provided predicate function returns
true
for at least one element in a collection.Checks if two numbers are approximately equal to each other.
Creates an array of numbers in the arithmetic progression, starting with the given positive integer and up to the specified limit.
Decodes a string of data which has been encoded using base-64 encoding.
Calculates the average of two or more numbers.
Finds the index of a given element in a sorted array using the binary search algorithm.
Calculates the number of ways to choose
k
items fromn
items without repetition and without order.Checks if the bottom of the page is visible.
Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.
Sorts an array of numbers, using the bubble sort algorithm.