| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | dev_langs | ms.assetid | caps.latest.revision | author | ms.author | manager | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Array.of Function (Array) (JavaScript) | Microsoft Docs |
01/18/2017 |
windows-client-threshold |
|
language-reference |
|
2884dda3-65d1-4990-9afe-87865c2d4f7f |
3 |
mikejo5000 |
mikejo |
ghogen |
Returns an array from the passed in arguments.
Array.of(element0[, element1][, ...][,elementN]);
element0,...,elementN
Optional. The elements to place in the array. This creates an array with n + 1 elements, and a length of n + 1.
This function is similar to calling new Array(args), but Array.of does not include special behavior when one argument is passed in.
The following example creates an array from passed in numbers.
var arr = Array.of(1, 2, 3);
// arr[0] == 1 The following example shows the difference between using Array.of and new Array.
var arr1 = Array.of(3);
// arr1[0] == 3
// With new Array, a single argument specifies
// the length of the new array.
var arr2 = new Array(3);
// arr2[0] is undefined
// arr2.length == 3
[!INCLUDEjsv12]