SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 33 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"


Debugging Your Code
It doesn??™t matter how simple your code is, you are guaranteed to have errors in your code at
some point. As a result, you??™ll need to have a way to understand what went wrong, why it went
wrong, and how to fix it.
Alert
Probably the most common technique of JavaScript debugging is using alert(). There??™s no
software to install and no complicated code to set up. Just pop a line into your code, place the
information you??™re looking for into the alert and see what comes up:
alert(varname);
An alert is ineffective, however, for tracing anything that is time sensitive or any values
within a loop. If something is time sensitive (for example, an animation), the alert throws
things off because it has to wait for your feedback before continuing on. If it??™s a loop, you??™ll
find yourself hitting the OK button countless times. If you accidentally create an infinite loop,
you have to force the browser to close entirely, losing anything else that was open, to regain
control of it??”and that??™s never fun!
Alerts can also be ineffective because they show only string data. If you need to know
what??™s contained within an array, you have to build a string out of the array and then pass it
into the alert.
Page Logging
Page logging is a handy trick and a step above using an alert. Create an empty
on the
page and use absolute positioning along with setting the overflow to scroll.


Pages:
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
Free English grammar and study guid Russian bride druga wojna światowa counter strike 1.6 hotel jelenia góra