the only thing i know how to javascript is using alert(). is there any other way to help debugging javascript ?
But fortunately, all modern browsers have a built-in JavaScript debugger. Built-in debuggers can be turned on and off, forcing errors to be reported to the user. With a debugger, you can also set breakpoints (places where code execution can be stopped), and examine variables while the code is executing.
Javascript provides the keyword Debugger to debug the code. When we add the debugger keyword in between our code, so after executing the code, a debugger panel will show up where we can make breakpoints and play/pause to check the value and understand according to it.
Using Firebug, and the web development tools on other browsers, you can use commands such as
console.log(myVar);
to watch for variables, instead of the more disruptive alert
. With the consoles on most development tools, you can also run arbitrary pieces of Javascript from there without having to modify the actual code, which can help immensely with with debugging Javascript. Oh, and the break on error function helps too.
When you open up Firebug you see something like this. Click on the console tab and enable it:
Enter your code after the >>>
. Just for fun try something like $('body').css('-moz-transform', 'rotate(10deg)')
:D
firebug or similar browser plugins
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With