JavaScript only has one simple type -- namely: |
var anumber = 137; // or the SAME type var |
var astring = "1"; // to define a string |
The loose typing in JavaScript, allows interpreter to creatively interpret an expression and default (this is change from early documentation which claimed type taken from leftmost variable) is that strings have precedence over numbers so that for instance: |
x = astring + anumber; // results in x = "1137" |
use parseInt and parseFloat to extract numerical values from strings (see later) |
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) and one can use \n for newline and \t for TAB |
Boolean literals are either true or false |
Comments are /* any stuff including newlines */ or |
Javascript statements; // This is a comment until new line |