Javascript (Arrays, Objects, Regex, Functions)




CS174

Chris Pollett

Apr 12, 2017

Outline

Arrays

More Arrays

Let's Build Something

Make an HTML page with a form on it with text fields labeled Title, Author, Publisher, Year and with a button Save. Clicking the button Save should store into a Javascript object book the fields title, author, publisher and year. It then causes an alert to be displayed with the contents of the book object neatly drawn.

Post your answers to the Let's Build Something Thread.

Functions

Function Example

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;
}

Constructors

Methods

More on the Prototype Property

Variable Hoisting

The Module Pattern

More Faking Visibility

Pattern Matching

Pattern Special Characters

Slash Patterns

Yet more special characters

Pattern Modifiers

More Pattern Methods