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 e.g. [1,2,3], but in a function form. [see JS: Function Form vs Operator]

see also JS: Array Constructor.

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