Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Uncaught SyntaxError: fails on first Regex function, but not second

this question is different because the first function errors, but the other identical functions work fine.

Question: Why does the first function fail, but not the second? …in these JS Regex functions, from a 3rd party lib used to parse float/ints etc with the help of the regex function.


Please advise how do I troubleshoot fix this error?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Uncaught SyntaxError: missing ) after argument Regex

>Solution :

According to https://developer.mozilla.org/en-US/docs/Glossary/Syntax_error

Syntax errors are detected while compiling or parsing source code.

Once the browser encounters a syntax error, it stops parsing the script and reports the error immediately.

You can run these two snippets in DevTools console to see it in action:

const a = text => text.replace(/.*/ g)
const b = text => text.replace(/.*/ g)
// VM744:1 Uncaught SyntaxError: missing ) after argument list
// Only reported the first error on line 1,
// even though the code after isn't valid JavaScript either

const a = text => text.replace(/.*/g)
const b = text => text.replace(/.*/ g)
// VM754:2 Uncaught SyntaxError: missing ) after argument list
// Now that the error is fixed on line 1,
// the parser moved on to find the error on line 2 and reports it

enter image description here

Hope this helps!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading