November 26, 2017

ES6 Array.from function

A useful ES6 function for converting an object into an array.

The Array.from() function in ES6 easily turns most objects recognised as a group of items into a standard array which you can then use other helpful ES6 functions on like map().

<div class="burritos">
	<p>Pulled pork</p>
const burritos = document.querySelectorAll('.burritos > p');
const burritosArray = Array.from( burritos);
const names = burrito => burrito.textContent );