Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!