jschap09 - Tutorial 9: Debugging JavaScript JavaScript -...

Info iconThis preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon
Tutorial 9: Debugging JavaScript JavaScript - Comprehensive
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Section A: Basic Debugging Techniques
Background image of page 2
Objectives In this section, the students will learn: About debugging concepts How to interpret error messages How to trace errors with the alert() method How to trace errors with the write() and writeIn() methods How to use comments to locate bugs About additional debugging techniques
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Understanding Debugging Three types of errors can occur in a program: Syntax errors Logic errors Run-time errors Syntax errors occur when you enter code that the interpreter does not recognize
Background image of page 4
Understanding Debugging Syntax errors in JavaScript include invalid statements or statements that are entered incorrectly If the JavaScript interpreter encounters a problem while a program is executing, that problem is called a run-time error Logic errors are problems in the design of a program that prevent it from running as anticipated
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Error Messages The first line of defense in locating bugs in JavaScript programs are the error messages you receive when the JavaScript interpreter encounters a syntax or run-time error Two important pieces of information displayed in error message dialog boxes by both Navigator and Internet Explorer are: The line number in the document where the error occurred A description of the error
Background image of page 6
Error Messages Regardless of which browser you use, error messages should only be used to find the general location of an error in a program and not as the exact indicator of an error To use error messages to help locate bugs in a JavaScript program follow the directions on page 453 of the textbook
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Tracing Errors with the alert() Method Tracing is the examination of individual statements in an executing program The alert() method provides one of the most useful ways to trace JavaScript code One drawback to using multiple alert() methods to trace values is that you must close each dialog box for your code to continue executing To use alert dialog boxes to help locate bugs in a JavaScript program refer to the instructions on page 457 of the textbook
Background image of page 8
CalculatePay() Function with a Logic Error
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CalculatePay() Function with an alert() Method to Trace Program Execution
Background image of page 10
CalculatePay() Function with Multiple alert() Methods to Trace Program Execution
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Final Dialog Box in Corrected VitalInfo.html File
Background image of page 12
Tracing Errors with the write() and writeIn() Methods There may be situations in which you want to trace a bug in your program by analyzing a list of values, rather than by trying to interpret the values displayed in alert dialog boxes on a case-by-case basis You can create such a list by opening a new browser window and printing values, using the write() and writeIn() methods
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Tracing Errors with the write() and writeIn() Methods
Background image of page 14
writeIn() Methods
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/13/2011 for the course MIS 241 taught by Professor Tse during the Spring '11 term at Moraine Valley Community College.

Page1 / 69

jschap09 - Tutorial 9: Debugging JavaScript JavaScript -...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online