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

234
Vistas
Time Complexity of a simple spreaded array chained with .map() in Javascript?

For example,

const arr = [1,2,3]
let multipliedByTwos = [...arr].map(n=>n*2)

I'm wondering what's the time complexity to produce multipledByTwos.

I know spreading [...arr] is O(N), and .map() in this case is also O(N). But what if they're chained together like the code example above? I assume still O(N)? Because it spreads first (O(N)) and then maps it (O(N)).

Something like this O(N) + O(N) === 2O(N), which really is just O(N). Is this correct? Or should it be O(N^2) because the chaining actually multiplies the time complexity rather than adding them? I'm kinda lost a bit in this concept.

EDIT: Im not asking whether O(N) * 2 is O(N). But im asking about my general understanding of the chaining of [...arr] and .map().

Thanks.

about 4 years ago · Juan Pablo Isaza
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