Google Chrome provides nice facility to debug JavaScript by using Its console and sources
Using Console: - You can print the variables to console
without affecting the UI. Make sure that you comment or delete your console.log
function before code is going into a production machine. Console.log will throw
error in Internet Explorer.
If you use console.log to print an object, you will get all
the information about that object.
Using console.log you will get the information about a JavaScript
Class.
Using Source:- Using source tab in the property inspector,
you can see all the JavaScript related files used by your web page.
Here you can set break points on your code, line by line execution,
skipping into the next function everything is possible. Once you set the break
point, just refresh your page so he execution starts from the beginning and
stopped at the line you marked. From there, you can go for line by line
execution and you can see all the variables and its values during the run time.
Usually while JavaScript development, you will make some
code changes in JavaScript, then you will refresh the page and test those
changes. But you can do it the same in
sources.
You can Open your JS in the source tab, make changes there,
press cntrl+s so your code will get recompiled into that instance, without a
refresh or deployment of js code you can start testing.


No comments:
Post a Comment