JS: Array.of

By Xah Lee. Date: . Last updated: .

(new in ECMAScript 2015)

Array.of(v1, v2, etc)

Return a new array with elements of v1, v2, etc.

🟢 TIP: This function is similar to array literal expression but in a function form. Function form lets you manipulate expressions at run-time.

console.log(Array.of(3, 4, "x"));
// [ 3, 4, "x" ]