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

227
Views
Why does Number constructor fail to parse numbers with separators?

Since JavaScript has numeric separators (_, U+005F), why does Number("3_0") return NaN? Shouldn't it work like Number("0x08") which returns 8?

Number.isNaN(Number("3_0")) // true
Number.isNaN(Number(3_0))   // false
Number("3_0") === 30        // false
Number(3_0) === 30          // true
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

According to the spec, there are a few differences between the syntax accepted for numeric literals and the syntax accepted for a string value when being converted to a numeric value.

One of the differences is

A StringNumericLiteral cannot include a NumericLiteralSeparator.

If I have to guess, the reason is that accepting such characters would change the behavior of existing valid JavaScript code, which may break working applications.

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!