Last Modified: 1/29/08
  Computer Training
JavaScript as a Programming Language

Credit: Kirk Born (St Sci/NASA)

Elements of JavaScript

We will explain JavaScript mostly through examples. We assume that you are familiar with "C-like" languages and so will not explain those elements of the language that are similar to "C". Client-Side JavaScript:
  • Operates on the client-side so it reacts much faster, with more client-side capabilities, and greater security, than server-side languages
  • Is an interpretive language, so its basic operation is slower than a compiled language, but is much more flexible and has a more free and easy syntax
  • Has a large number of reserved words: the following words are absolutely, positively reserved:
      
    break    false    in     this   void
    continue for      new    true   while
    delete   function null   typeof with
    else     if       return var
         
    plus about 120 or so words that are "sorta" reserved or might be reserved in the future. See the complete list in David Flannagan's "JavaScript, the Definitive Guide".

The main components of JavaScript are:

  • Expressions and operators: the usual "C-like" with a few exceptions: "new ", "typeof", and "+" used for string concatenation
  • Statements: the usual "C-like" statements with a few exceptions: "for (prop in object)...", "with (object)..."
  • Strings: declaration, concatenation, length, split, concatenation with numbers, charAt, substring, indexOf. See Test of Strings
  • Functions: these differ in many ways from "C-like" languages. See Functions and Arguments. for many of the important features of JavaScript functions.
  • Arrays: these differ from most other languages. See Test of Arrays for many of their features.

JavaScript, like many languages, makes a distinction between value versus reference, particularly in terms of copies, comparisons, and arguments. Basically, Booleans, numbers, and strings are copied, passed, and compared by value, where as all others (objects, arrays, and functions) are copied, passed, and compared by reference. See this for some effects of value-versus-reference handling in functions.

Previous Home Next

Course Topics

Client-Side JavaScript

JavaScript as a Programming Language

Execution of JavaScript

'JavaScript Document Object Model

Programming with JavaScript

Using Cookies in JavaScript

JavaScript and DHTML

Homework Assignments

 
Previous Home Next

Other Topics:   JavaScript Tutorial   |   Another Tutorial   

©1999 UW Technology