| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/of | [Back] [Original] |
Get to know MDN better
console.log(Array.of("foo", 2, "bar", true));
// : Array ["foo", 2, "bar", true]
console.log(Array.of());
// : Array []
Array.of()
Array.of(element1)
Array.of(element1, element2)
Array.of(element1, element2, /* , */ elementN)
Array.of() Array() Array.of(7) 7 Array(7) length 7 undefined 7
Array.of(7); // [7]
Array(7); // 7
Array.of(1, 2, 3); // [1, 2, 3]
Array(1, 2, 3); // [1, 2, 3]
Array.of() Array of() of() Array this of() length this Array
Array.of(1); // [1]
Array.of(1, 2, 3); // [1, 2, 3]
Array.of(undefined); // [undefined]
of()
function NotArray(len) {
console.log("NotArray called with length", len);
}
console.log(Array.of.call(NotArray, 1, 2, 3));
// NotArray called with length 3
// NotArray { '0': 1, '1': 2, '2': 3, length: 3 }
console.log(Array.of.call(Object)); // [Number: 0] { length: 0 }
this Array
console.log(Array.of.call({}, 1)); // [ 1 ]
| ECMAScript 2027 LanguageSpecification # sec-array.of |
Arrayat()concat()copyWithin()entries()every()fill()filter()find()findIndex()findLast()findLastIndex()flat()flatMap()forEach()includes()indexOf()join()keys()lastIndexOf()map()pop()push()reduce()reduceRight()reverse()shift()slice()some()sort()splice()toLocaleString()toReversed()toSorted()toSpliced()toString()unshift()values()with()[Symbol.iterator]()Object/Function| Web Proxy Viewer | New URL | Original Page |