JavaScript overview


— a 15min lecture before getting into details

  1. Language features
    1. interpreted OO scripting language, most commonly used in Web browsers, i.e. "client-side" scripting
    2. similar syntax as Java, C/C++
      1. case-sensitive, which can be confusing with working with case-insensitive HTML
        • because JavaScript objects and properties often represent HTML tags and attributes
      2. optional semicolons
    3. loose typing - no type associated when declaring, even declaration is optional
      1. primitive types: numbers, strings, Booleans, all of which have convenient wrapper classes
        1. all numbers are double-precision floating-point values
        2. character is string of length 1
        3. strings are compared by value in contrast by reference as in Java
        4. strings are immutable in JavaScript
      2. Reference types
        1. objects, essentially "associative arrays" because properties are allowed to be accessed via variables
          1. allowed to add or delete properties to existing object, i.e. you can extend other people's code
        2. arrays
          1. "thin layer" atop objects to support indexed access
          2. variable length
          3. mixture of values (types)
          4. many array methods are inspired by Perl
        3. functions are values - not only can it be defined and invoked, but also
          1. assigned and stored in variables or as object properties (methods)
          2. passed as arguments
          3. returned by other functions
        4. functions can be invoked with a different number of arguments as in its definition
      3. built-in classes: Date, RegExp, Error
      4. Automatic conversion is powerful, but should be used with caution
    4. prototype-based inheritance
      1. Pseudoclass
    5. supports garbage collection
    6. dialect as the standardized EMCAScript
      1. JScript of IE is similar
      2. Current version 1.8, but fairly stable since 1.5
      3. Movement of JavaScript 2.0, strong typing, tabled for long
  2. Client-side JavaScript
    1. embedded in browser, exposed with APIs to manipulate
      1. browser window
        1. frame hierarchy
        2. browser
        3. navigation history
      2. document
        1. legacy DOM - HTML elements in arrays and named "forms, form elements, images, applets, links" HTML elements
        2. DOM represented as a tree - you can traverse this tree
      3. CSS styles
        1. font, color type of representation
        2. position, layer and visibility (for animation)
      4. events
        1. HCI events, document events, HTML events
      5. forms
        1. form validation
      6. HTTP
        1. submitted requests to Web servers w/o reloading page - a thrust behind Web apps
        2. 3715 has a separate lecture on Ajax
  3. In what aspects is JS used in Web apps
  4. How to use JSDG
    1. Four parts:
      1. Core JavaScript
      2. Client-side scripting
      3. References for core JavaScript
      4. References for client-side scripting
    1. Important summaries:
      1. Type conversion: Table 3-3 (p39)
      2. Datatype manipulation in JavaScript: Table 3-5 (p48)
      3. CSS 2.1 style attributes and their names: Table 16-1 (P347)