Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
Initialise and mutate array in one line

I want to get a data set and splice off some irrelevant lines, preferably in one line.

Using

let data = tgSh.getDataRange().getValues();
data.splice(0, headers.getRow());

...works fine but combining the two lines as:

let data = tgSh.getDataRange().getValues().splice(0, headers.getRow());

...just returns the spliced values and not a mutated data array.

Is there anyway to do this? Not the end of the world but just learning as I go

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use slice(). It doesn't mutate, it returns a new array. Butince you no longer have a reference to the original array, you can't tell the difference (except for some extra memory allocation, which will be collected quickly by GC).

let data = tgSh.getDataRange().getValues().slice(0, headers.getRow());
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda