Estoy creando una Array con una longitud de 1,000,000 y llenándola con 1 como esta:
const bigArray = Array.from({ length: 1000000 }, () => 1); cuando presiono un nuevo elemento en ese Array en línea como se muestra a continuación, Nodejs registra un error:
// This rise an TypeError: bigArray.push is not a function const bigArray = Array.from({ length: 1000000 }, () => 1).push(3); // Although this one works right const bigArray = Array.from({ length: 1000000 }, () => 1); bigArray.push(3)Como alternativa a ese enfoque para mantener las cosas en una asignación, puede distribuir la matriz en una nueva matriz:
const bigArray = [...Array.from({ length: 1000000 }, () => 1), 3];