Please note that this tutorial will look best in a standards-compliant browser, such as Firefox .
- The official ECMA specification for ECMAScript v3 (poorly written pdf)
- Very verbose introduction/tutorial from our friends at QuirksMode
All of these statements are incorrect:
Here, we don't test to see if the browser is IE 220.127.116.11, or Netscape 3.3.221, we simply ask the question, "Does this property/function/whatever exist?" This way, we don't care about the identity of the browser, we just care about what functionality the browser supports. If the next version of some browser supports something it didn't before, no well-written scripts will need changing. Note that the != undefined is not necessary, but it makes it clear that we are testing for existence of an object member and not a boolean value.The struct equivalent
The following is equivalent, but slightly more dangerous due to the
Strictly speaking, a variable is null if it exists but has no value, whereas "something" is null if it's not even a variable. More will be added later; see these notes in the time being.Funkiness with null and ||