jskatas.org Continuously Learn JavaScript. Your Way.

Array API: Array.from()

Convert a not-array into an array.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

Array.from converts an array-like object or list into an Array

  • call Array.from with an array-like object
  • a DOM node`s classList object can be converted
  • convert a NodeList to an Array and filter() works on it

custom conversion using a map function as second param

  • we can modify the value before putting it in the array
  • and we also get the object`s key as second parameter