Java Reference
In-Depth Information
In other browsers, you'll need to look in the JavaScript console, which you can view by pressing
Ctrl+Shift+J on your keyboard. You can also view the console by navigating through the browser's
menu. You learn how to do this later.
In addition, you must remember that function definitions also have parameters, which if not
declared correctly can lead to the same type of error.
Take a look at the following code:
function foo(parametrOne) {
alert(parameterOne);
}
If you call this function, you get an error message similar to the one shown in Figure 18-2.
figure 18-2  
The error here is actually a simple typo in the function definition. The function's parameter should
read parameterOne , not parametrOne . What can be confusing with this type of error is that
although the browser tells us the error is on one line, the source of the error is on another line.
Case sensitivity
This is a major source of errors, particularly because it can be difficult to spot at times.
For example, spot the three case errors in the following code:
var myName = "Jeremy";
If (myName == "jeremy") {
alert(myName.toUppercase());
}
The first error is the if keyword; the code above has If rather than if . However, JavaScript
won't tell us that the error is an incorrect use of case, but instead the browser will tell us
Object expected or that If is not defined . Although error messages give us some idea of what's
 
Search WWH ::




Custom Search