| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Array/Array | [Back] [Original] |
Get to know MDN better
Esta pgina ha sido traducida del ingls por la comunidad. Aprende ms y nete a la comunidad de MDN Web Docs.
This feature is well established and works across many devices and browser versions. Its been available across browsers since julio de 2015.
El constructor Array() se utiliza para crear objetos Array.
new Array(element0, element1, /* ,*/ elementN)
new Array(arrayLength)
Array(element0, element1, /* ,*/ elementN)
Array(arrayLength)
Nota:
Array() puede ser llamado con o sin new. Ambos crean una nueva instancia de Array.
elementNUn array de JavaScript se inicializa con los elementos dados, excepto en el caso donde se pase un solo argumento al constructor de Array y ese argumento sea un nmero (vase el parmetro arrayLength ms abajo). Tenga en cuenta que este caso especial slo se aplica a los arrays de JavaScript creadas con el constructor Array, no a los arrays literales, creadas con la sintaxis de corchetes.
arrayLengthSi el nico argumento pasado al constructor de Array es un nmero entero entre 0 y 2^32 - 1 (incluido), ste devuelve un nuevo array de JavaScript con su propiedad de length establecida a ese nmero (Nota: esto implica un array de ranuras vacas de arrayLength, no ranuras con valores reales undefined ver sparse arrays).
RangeErrorSe lanza si slo hay un argumento (arrayLength) y su valor no est entre 0 y 2^32 - 1 (incluido).
Los arrays pueden ser creados usando la notacin literal:
const fruits = ["Apple", "Banana"];
console.log(fruits.length); // 2
console.log(fruits[0]); // "Apple"
Los arrays pueden ser creados usando un constructor con un solo parmetro numrico. Un array con su propiedad length establecida a ese nmero y los elementos del array son ranuras vacas.
const fruits = new Array(2);
console.log(fruits.length); // 2
console.log(fruits[0]); // undefined
Si se pasa ms de un argumento al constructor, se crea un nuevo Array con los elementos dados.
const fruits = new Array("Apple", "Banana");
console.log(fruits.length); // 2
console.log(fruits[0]); // "Apple"
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-array-constructor |
ArrayThis page was last modified on 21 jul 2025 by MDN contributors.
ArrayArray.prototype.at()Array.prototype.concat()Array.prototype.copyWithin()Array.prototype.entries()Array.prototype.every()Array.prototype.fill()Array.prototype.filter()Array.prototype.find()Array.prototype.findIndex()findLast()findLastIndex()Array.prototype.flat()Array.prototype.flatMap()Array.prototype.forEach()Array.prototype.includes()Array.prototype.indexOf()Array.prototype.join()Array.prototype.keys()Array.prototype.lastIndexOf()Array.prototype.map()Array.prototype.pop()Array.prototype.push()Array.prototype.reduce()Array.prototype.reduceRight()Array.prototype.reverse()Array.prototype.shift()Array.prototype.slice()Array.prototype.some()Array.prototype.sort()Array.prototype.splice()Array.prototype.toLocaleString()toReversed()Array.prototype.toSorted()toSpliced()Array.prototype.toString()Array.prototype.unshift()Array.prototype.values()with()Array.prototype[@@iterator]()Object/FunctionYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |