Process 1 : Errors and Warnings in Code Editor
If you are using any code editor, then you can efficiently resolve errors. Let’s look at the example of Visual Studio Code Editor below.
In the above snippet, you can see that I deliberately removed parentheses before the semicolon. VS Code is smart enough to tell you that you are missing closing parentheses. Also, on the left, you can see index.js file turned Red showing one error in the code.
Let’s look at another example. Here VS Code also failed to find an error in code.
In the above snippet, you can see that I have misspelled alert function name. But VS Code saying nothing! In this case, you can run your code without realizing your mistake, and you will find that browser is not showing alert pop up.
What would you do in this case?
Process 2 : Errors Inside Console Window of Browser
Run your code. When the browser opens, You will see that your functionality is not working. In the above case, the alert box will not appear because of the wrong spelling of function name. To find an error, Go to the developer tools of the browser. You can find it in a menu of browser or press F12 to open it.
In that, you will find the Console tab. Click on that you will find the error. Fix the error in the code by reading instruction given in the console.
In the case of an alert function, the wrong spelling caused the error logged in the console window of the chrome browser.
You can see that there is an error that says ‘aler is not defined.’ We know that we have misspelled alert function name. There is no function defined with name aler. Fix it. Pop up will appear.