Start of main content## JavaScript Array 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.

### JavaScript Data Structures - Binary Tree

JavaScript, Object

A binary tree is a data structure consisting of a set of linked nodes representing a hierarchical tree structure, in which each node can have at most two children.

### Frequency Map Data Structure

JavaScript, Object

A custom data structure to keep track of value frequencies in an array.

### Ungroup array elements based on function

JavaScript, Array

Creates an array of elements, ungrouping the elements in an array produced by zip and applying the provided function.

### JavaScript Data Structures - Binary Search Tree

JavaScript, Object

A binary search tree is a data structure consisting of a set of ordered linked nodes representing a hierarchical tree structure, in which each node can have at most two children.

### Pull values from array based on function

JavaScript, Array

Mutates the original array to filter out the values specified, based on a given iterator function.

### 4 JavaScript Array methods you must know

JavaScript, Array

JavaScript arrays have a very robust API offering a plethora of amazing tools. Learn the 4 must-know JavaScript array methods in this quick guide.

### Tip: Make any JavaScript value iterable

JavaScript, Array

Did you know you can define an iterator for any JavaScript value? This quick tip will show you how.

### Tip: Remove duplicates from a JavaScript array

JavaScript, Array

Easily remove duplicates from a JavaScript array using the built-in

`Set`

object.### Tip: Get the index of an array item in a JavaScript for...of loop

JavaScript, Array

Did you know you can get the index of an array item in a JavaScript for...of loop? Learn how with this bite-sized tip.

### JSON to CSV

JavaScript, Array

Converts an array of objects to a comma-separated values (CSV) string that contains only the

`columns`

specified.### Compact object

JavaScript, Object

Deeply removes all falsy values from an object or array.

### Heap sort

JavaScript, Algorithm

Sorts an array of numbers, using the heapsort algorithm.

### Ungroup array elements

JavaScript, Array

Creates an array of arrays, ungrouping the elements in an array produced by zip.

### Tip: Min and max value in a JavaScript array

JavaScript, Array

When working with numeric arrays in JavaScript, you might find yourself in need of finding the minimum or maximum value. Here's a quick and easy way to do it.

### Array permutations

JavaScript, Array

Generates all permutations of an array's elements (contains duplicates).