3.3. Language Anomalies

Despite using a familiar syntax with keywords you probably recognize, there are a couple of things about JavaScript that can catch you by surprise. The way objects are compared for equality is probably different than you expect. Moreover, the JavaScript language has the notion of objects being null or undefined. If you do not recognize these unique characteristics of JavaScript, you can get yourself into trouble and spend a lot of time debugging to find the source of the problem.

3.3.1. What Is Equality?

If you are just getting started with JavaScript and coming from a compiled language like C# or Visual Basic, be prepared for a whole new kind of debugging challenge! Not only is JavaScript typeless; it doesn't use a compiler! Remember it is interpreted. The only way to detect syntax errors, even simple ones, such as improper case, is to run the code. In addition, you must exercise every possible code path just to do what a compiler would do for you. This is one example of the huge benefit you can get from using the Microsoft ASP.NET AJAX Client Script Library: There is a large amount of fully debugged code ready for you to use in your own applications!

One thing to note is that JavaScript shares its treatment of Boolean values with the C programming language. JavaScript and C need a double equal sign for a logical test, and they use a single equal sign for an assignment. This can become painfully apparent when you find a missing equal sign in a comparison ...

Get Professional ASP.NET 3.5 AJAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.