Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Javascript syntax errors? [closed]

I am writing a JavaScript section of code and making huge amounts of silly mistakes in the syntax. But the only way to find what line the error is on is to start commenting out the section of code I just wrote and reload it into the browser to narrow down where my missing ');' is.

How do you "compile" a JavaScript source to make sure it is syntactically correct so that I can debug it in the browser?

like image 416
Robert Avatar asked Jan 22 '10 19:01

Robert


People also ask

How do I find JavaScript errors?

Demo page: JavaScript error reported in the Console tool Or, press F12 . DevTools opens next to the webpage. In the top right of DevTools, the Open Console to view errors button displays an error about the webpage. Click the Open Console to view errors button on the top right.

What Is syntax error JavaScript?

An exception caused by the incorrect use of a pre-defined syntax. Syntax errors are detected while compiling or parsing source code. For example, if you leave off a closing brace ( } ) when defining a JavaScript function, you trigger a syntax error.


1 Answers

Ctrl + Shift + J in firefox, if you don't catch your mistakes until runtime. Of course firebug works better, but this is a quick way.

like image 160
Carson Myers Avatar answered Oct 14 '22 14:10

Carson Myers