JS: Array.of ♠

By Xah Lee. Date: . Last updated: .

(new in ECMAScript 2015)

Array.of(val1, val2, etc)

Return a new array with elements of val1, val2, etc.

🟢 tip: This function is similar to Array literal expression, but in a function form. [see JS: Function Form vs Operator] Also similar to Array Constructor.

console.log(Array.of("a", "b", "x"));
// [ "a", "b", "x" ]