The best practice to find out the error is to debug the code. The code can be debugged easily by using web browsers like Google Chrome, Mozilla Firebox.
Here, we will find out errors using built-in web browser debugger. To perform debugging, we can use any of the following approaches:
Using console.log() method
The console.log() method displays the result in the console of the browser. If there is any mistake in the code, it generates the error message.
Let's see the simple example to print the result on console.
To open the console on browser, press F12 key.
Using debugger keyword