Start of main content## JavaScript Algorithms

The JavaScript algorithms collection includes implementations and examples of popular algorithms in ES6. Algorithmic snippets are primarily a learning resource, as they might already be implemented natively or require optimizations to run in production.

### Powerset

JavaScript, Math

Returns the powerset of a given array of numbers.

### Bubble sort

JavaScript, Algorithm

Sorts an array of numbers, using the bubble sort algorithm.

### Greatest common divisor

JavaScript, Math

Calculates the greatest common divisor between two or more numbers/arrays.

### Insertion sort

JavaScript, Algorithm

Sorts an array of numbers, using the insertion sort algorithm.

### Geometric progression

JavaScript, Math

Initializes an array containing the numbers in the specified geometric progression range.

### Binary search

JavaScript, Algorithm

Finds the index of a given element in a sorted array using the binary search algorithm.

### Levenshtein distance

JavaScript, String

Calculates the difference between two strings, using the Levenshtein distance algorithm.

### Fibonacci

JavaScript, Math

Generates an array, containing the Fibonacci sequence, up until the nth term.

### Linear search

JavaScript, Algorithm

Finds the first index of a given element in an array using the linear search algorithm.

### Prime factors of number

JavaScript, Math

Finds the prime factors of a given number using the trial division algorithm.

### Vector distance

JavaScript, Math

Calculates the distance between two vectors.

### Shuffle array

JavaScript, Array

Randomizes the order of the values of an array, returning a new array.

### Least common multiple

JavaScript, Math

Calculates the least common multiple of two or more numbers.

### Hamming distance

JavaScript, Math

Calculates the Hamming distance between two values.

### Binomial coefficient

JavaScript, Math

Calculates the number of ways to choose

`k`

items from`n`

items without repetition and without order.