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

170
Views
Is abstraction a factor in using Javascript array methods that do not mutate original data and return a new array?

Please correct me if I am wrong: Is the main benefit of .map(), .filter() other than the function they perform the fact that they provide a layer of abstraction? Returning new arrays with choice bits of data without mutating the original seems like abstraction in motion.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In fact, the map function borrows its origins in the functional paradigm principle (https://en.wikipedia.org/wiki/Functional_programming). In that vision of programming, we tend to use "pure functions", which are functions that don't mutate any of its arguments.

So, it's not really an abstraction but a choice:

  • Do you want to mutate your arguments? Change the array live
  • Do you want a transformed copy of your data? Use map

In some cases, you don't want to change the original data, so, map may be a fit by default.

In some other cases, you have the choice. Using map has the advantage of reducing the possibility of side-effects (ex: other parts of the app sharing the same array, and not expecting to change), at the cost of duplicating data.

So, no one is better than the other, it really depends on what do you want to do.

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