javascript errors and debugging

6
Javascript Errors and Debugging Web Design Sec 6-3 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials

Upload: kasie

Post on 24-Feb-2016

69 views

Category:

Documents


0 download

DESCRIPTION

Javascript Errors and Debugging. Web Design Sec 6-3. Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials. Objectives. The student will: Be able to tell when Javascript has triggered an error in your web browser - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Javascript Errors and  Debugging

Javascript Errors and Debugging

Web DesignSec 6-3

Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials

Page 2: Javascript Errors and  Debugging

Objectives• The student will:

• Be able to tell when Javascript has triggered an error in your web browser

• Have gained practice understanding Javascript error messages and applying them toward correcting errors in Javascript code

Page 3: Javascript Errors and  Debugging

Finding Bugs in JavaScript

• If your JavaScript doesn't work as you expected it to, that might mean you have a bug in your code. 

• Typos are a common source of bugs in JavaScript. If your script isn't working, check the following:

• Missing punctuation. Be sure every opening bracket has an accompanying closing bracket.

• Unclosed character string. Whenever you're working with text in JavaScript (for example, when you displayed text in an alert box in the previous lesson), that text must be enclosed in quotation marks. You can use either single quotation marks ('...') or double quotation marks ("...") but be sure every opening quotation mark is closed at the end of the string of characters.

Page 4: Javascript Errors and  Debugging

Finding Bugs in JavaScript

• Misspelled variable. JavaScript is case-sensitive. In the example in the previous lesson, you created a variable called myText. That isn't the same as MyText; one has a lower-case M, the other does not. If you define a variable called myText, then try to execute the command alert(MyText) the script would fail because MyText doesn't exist.

Page 5: Javascript Errors and  Debugging

Summary• Debugging is the art of finding bugs in your code,

and fixing them• Look carefully at all the opening and closing brackets

and quotes, then check all the spelling.

Page 6: Javascript Errors and  Debugging

Rest of Today• Download the homework for today.• There is a Google form in which you are to

identify the three errors in the code.• Complete this today!