Static Properties and Methods

Array.from()

Creates a new Array instance from an iterable.Array.from(obj, mapFn, thisArg) has the same result as Array.from(obj).map(mapFn, thisArg), except that it does not create an intermediate array.

Array.isArray()

Returns true if a variable is an array, if not false.

Array.of()

Creates a new Array instance with a variable number of arguments, regardless of the number or type of the arguments.


RESETRUNFULL
<!DOCTYPE html><html><body><script>


   var a = Array(3);
   console.log(a.length);  // 3
   console.log(Array.isArray(a));  // true
      a = Array.of(3);
   console.log(a.length); // 1
      b = a;                   // passed by value
   c = Array.from(a); // passed by value
   delete a;
   console.log(b);  // [3]
   console.log(c);  // [3]
      console.log(Array.from('abc'));  // ['a','b','c']
   console.log(Array.from(new Set(['foo',window])));                                                          // ['foo',window]
   console.log(Array.from(new Map([[1,2],[2,4],[4,8]])));                                                   // [[1,2],[2,4],[4,8]]
   console.log(Array.from([1, 2, 3], x => x + x));                                                              // [2,4,6]
   console.log(Array.from({length: 5}, (v, i) => i));                                                           // [0,1,2,3,4]                                                                                    // (‘duck typing’ faking array)

</script></body><html>

Array.fromAsync(asyncOrSyncIterable, mapFn, thisArg)

Added in ECMAScript 2026 as the natural async counterpart to Array.from(), returns a Promise for an array collected from an async iterable (5.8) — awaiting each yielded value/promise in turn — or, just as usefully, from a plain synchronous iterable whose values happen to be Promises, which Array.from() alone would collect as unresolved Promise objects rather than their eventual values.


async function* asyncNumbers() {
  yield 1;
  yield await Promise.resolve(2);
  yield 3;
}

const a = await Array.fromAsync(asyncNumbers());
console.log(a);

const b = await Array.fromAsync([Promise.resolve('x'), Promise.resolve('y')]);
console.log(b);   // not [Promise, Promise], as plain Array.from() would give

[1, 2, 3] ['x', 'y']