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

99
Views
Using a function in Array.from

I would like to parse integers as they are written to a new array. Here are two versions I have:

let aa = '123';
let bb = Array.from(aa, (val) => parseInt(val));
// [1,2,3] OK
let cc = Array.from(aa, parseInt);
// [1, NaN, NaN]
console.log(aa, bb, cc);

Why does the first method work, but the second method does not (doesn't parseInt take one required argument, so would be the same as the first method?)

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

0

parseInt() takes two arguments, the second argument defines the radix (base) for the parsed number.

P. S. You could use the Number constructor as the second argument:

let cc = Array.from(aa, Number);
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!