Basic HTML version of Foils prepared 23 June 1997

Foil 20 JavaScript Values, Names, etc.

From JavaScript Tutorial for Certificate Course UC Web applications Certificate -- Summer 97. by Geoffrey C. Fox, Tom Scavo

Various Additions of Numbers and Strings! for Foil 20
JavaScript only has one simple type, namely:
var anumber = 137; // use var to define a number
var astring = "1"; // or to define a string
Loose typing in JavaScript allows interpreter to creatively interpret an expression. Note that strings take precedence over numbers:
var x = astring + anumber; // results in x = "1137"
(Early versions of JS inferred the type from the leftmost variable.)
Use parseInt and parseFloat to extract numerical values from strings
Note special value null (no quotes) can be used as a null value
Strings can be delimited by '..text..' or "..text.." which are identical in meaning (unlike PERL). Also, one can use \n for newline and \t for tab (and a few others).
Boolean literals are either true or false
Comments come in two flavors:
/* any text including newlines */
statements; // comment terminated by newline



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998