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
1 JavaScript only has one simple type, namely:
2 var anumber = 137; // use var to define a number
3 var astring = "1"; // or to define a string
4 Loose typing in JavaScript allows interpreter to creatively interpret an expression. Note that strings take precedence over numbers:
5 var x = astring + anumber; // results in x = "1137"
6 (Early versions of JS inferred the type from the leftmost variable.)
7 Use parseInt and parseFloat to extract numerical values from strings
8 Note special value null (no quotes) can be used as a null value
9 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).
10 Boolean literals are either true or false
11 Comments come in two flavors:
12 /* any text including newlines */
13 statements; // comment terminated by newline

in Table To:


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