AJAX - The Complete Reference

(avery) #1

A


JavaScript Quick Reference


T


he syntax of core JavaScript language features is covered in this appendix as a quick
reference for Ajax developers. Given the goal for a concise presentation, the examples
are kept to a minimum. Readers looking for more depth, particularly in relationship
to the various supported objects, are encouraged to look online at sites such as Mozilla’s
JavaScript 1.5 guide (http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference)
or Microsoft’s MSDN section on scripting (http://msdn2.microsoft.com/en-us/library/
ms950396.aspx), or to pick up the companion book, JavaScript: The Complete Reference, by the
same author.

NNOT EOTE The ECMAScript 262 specification (www.ecma-international.org/publications/standards/
Ecma-262.htm ) is also a possible resource, but its readability leaves a bit to be desired, and it
does not cover any aspects of JavaScript that are browser specific.

Language Fundamentals


The following points are major characteristics of JavaScript as used in a Web browser:


  • Scripts are interpreted rather than compiled.

  • Excess whitespace is ignored when outside of a regular expression literal or a string.

  • Statements should be terminated with a semicolon. Though line returns can imply
    the end of a complete statement, it is a bad practice.

  • Data is weakly typed and type conversion is common to make statements work.

  • References to identifiers are resolved using lexical (static) scoping. The one exception
    to this is class properties of the RegExp object, which are dynamically scoped.

  • Variables spring into existence upon first use, though they should be predefined
    with a var statement in good practice.

  • There are two primary scopes: global and function level (local).

  • Multiple script files are combined to share the same scope, which leads to name
    collision issues.


551


Appendix


http://www.ebooks.org.in

Free download pdf