[Home]ECMAScript programming language

HomePage | Recent Changes | Preferences

The ECMAScript programming language, commonly known as JavaScript, is an object-oriented [scripting language]? specified by the ECMA?-262 standard. [Netscape Communications]? originally developed the language under the name "LiveScript" but then renamed it to "JavaScript" and gave it a syntax closer to that of the Java programming language developed by Sun Microsystems at roughly the same time Netscape was including support for Java technology in its Netscape Navigator browser.

ECMAScript is an object-oriented scripting language that connects through interfaces called Document Object Models (DOMs) to applications, especially to the server side ([web servers]?) and the client side ([Internet browsers]?) of internet applications. Many web sites use client-side ECMAScript technology to create powerful dynamic web applications. It may use Unicode and can evalutate regular expressions and Javascript expressions contained in a string (eval function).


When Javascript code is used in a HTML page it must be preceded by

<script language="JavaScript"><!--
and followed by
// --></script>


Variables are generally untyped. Variables are defined by either just assiging them a value or by using the var statement. The scope of a variable is either the web page if it has been defined outside any function or just within a function. Unfortunatly on the client side there is no easy way for accessing variables defined in another web page. Workarounds are using either cookies or a hidden frame or window in the background to store them.

Data structures

The primary data structure is an [associative array]? similar to hashes in the Perl programming language.


Javascript has several kinds of built in objects: These are Object, Array, String, Date and Math. Ohter objects belong to the DOM (window, form, links etc.).

By defining a constructor function it is possible do define objects. Javascript is a prototype based object-oriented language. One can add additional properties or methods to individual objects after they have been created. To do this for all instances of a certain object type one can use the prototype statement. Array are actually just objects. Elements may be accessed by numbers or associative names. Thus the following expressions may all be equivalent: myArray[1], myArray.north, myArray["north"].

Control structures

If ... else

if (condition)
   { statements1}
[else { statements2}]

While loop

while (condition)<br> { statements}<br>

Do ... while

while (condition);

For loop

 for ([initial-expression;] [condition;] [increment-expression])</br>
  {   statements}

Switch expression

 switch (expression)
 {   case label :       statement;  
     case label :       statement;
     default : statement;}

User interaction

Most interaction with the user is done by using HTML forms which can be accessed from Javascript. However there are as well some very simple means of communicating with the user

External links:

HomePage | Recent Changes | Preferences
This page is read-only | View other revisions
Last edited December 21, 2001 3:32 am by Hannes Hirzel (diff)