CS 175/286 - Lecture 10

Cover page image

Cay S. Horstmann

Understanding Javascript

Basic Syntax

Ways to invoke Javascript

Objects

Arrays

Functions

Below is an example of the syntax for declaring a function in Javascript

function swap(i, j, a)
{
    var tmp=a[i] /* explicitly defined variables 
                     have scope within the function
                     if I had declared the variable 
                     implicitly it would have global scope */
    a[i] = a[j]; a[j] = tmp
}

jQuery

Lab

Programmatic Changes