Skip to main content Accessibility Feedback

Arrays

Array.from()

Create a new array from an existing one, or transform an array-like object (like a NodeList) into an array. Pass the array (or array-like object) to copy in as an argument.

var sandwiches = ['turkey', 'tuna', 'ham', 'pb&j'];
var sandwichesCopy = Array.from(sandwiches);

Requires a polyfill for IE.