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

285
Views
Javascript weird behavior with REGEX parsed values

Can anyone please explain this to me? I am running the following code with the following input:

var results = [];
var tokenRegExp = /\s*([A-Za-z]+|[0-9]+|\S)\s*/g;
var m;
while ((m = tokenRegExp.exec(code)) !== null) {
    results.push(m[1].toString() //I added the toString to see if it would change anything, it did absolutely nothing. I was running it without before that);
}
return results;

The input of "code" is 3+3+6*6*5*8/9-6

And then I am seeing this extremely strange behavior in the console... where the output array appears to be correct until you expand it

enter image description here

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!