Structure and syntax

Case Sensitivity
All keywords like var or function must be in lowercase. All variable names, function names and identifiers are case sensitive. The following two variables are separate and independent of each other:

var Test = 6;
var test=4;
This code will cause a Javascript error:
function Test() {alert("Testing");}
function show_alert() {tesT();}

Like most programming and scripting languages, Javascript requires one space between keywords, names and identifiers. Extra spaces are ignored so you can use tabs and spaces wherever you need to make your code easier to read and debug.

Every line of Javascript must end in a semi-colon ;
Blank lines don't need sem-colons.

You can use C and C++ style comments:

// this is a single line comment
/* this is a
multi-line comment */
Javascript code in HTML pages should be contained within HTML comment tags:
<script language="Javascript" type="text/javascript">
// Javascript here
//   -->

Identifiers (Variable names, function names, labels.)
The first character in an identifier name must not be a digit. Javascript 1.0 does not allow identifiers to contain the $ character. The following are not legal identifier names:

var $value;
function 1way() {};
Javascript Keywords
break for this
case function true
continue if typeof
default import var
delete in void
do new while
else null with
export return
false switch
Reserved for future use

Declare variables using the keyword var. Javascript variables have no explicit data type and can contain data of any type.

var mynumber;
var mystring;
var myboolean;

This is part of Copyright © 1998-2004 Neil Williams
See the file about.html for copying conditions.