J3 Limited
 
Google
WWW J3Ltd
 
JavaScript Language

Contents

[Contents] [Tutorial] [Object Hierrachy] [Language] [Expressions] [Statements]


Introduction

Programming languages have come a long way since the early days of computing. JavaScript is an interpreted language. The program which executes JavaScript, reads each line, scanning it for JavaScript, if any is found it is analysed, then executed.

JavaScript is inserted into HTML documents by enclosing a JavaScript section between the <SCRIPT LANGUAGE="JavaScript"> and </SCRIPT> tags. Where JavaScript sections are placed depends on what it is meant to do:

  • If the result is required at a particular location on a page, the section is placed where the result is wanted
  • If the section contains code which other parts of the document make use of (functions for example), the code should be placed at the begining of the document (between the <HEAD> </HEAD> tags is a good place). Trying to make calls to sections which appear further down the document can fail, because those sections may not have been read yet.

[Contents] [Tutorial] [Object Hierrachy] [Language] [Expressions] [Statements]


Language Composition

A programming language allows symbols to be manipulated (expressions) and evaluated (operators).

The object hierarchy lists objects, such as a window or a document. There also fundamental things a programming language must deal with, such as numbers, text and true/false scenarios. These symbols are essential if useful programs are to be developed.

It is necessary to find out how expressions are written in JavaScript before trying to understand the language statements. This is because the language needs expressions to perform its tasks.

The followinfg link explains JavaScript expressions and related subjects.

A programming language allows a sequence of statements (commands) to be defined.

A programming language allows a designer (programmer to non programmers) to lay out a set of steps, or rules, needed to do something. At its simplest level it can be just one command, but not much can be achieved at this level.

    This is a simple example, which displays today's date:

    <SCRIPT LANGUAGE="JavaScript"> document.write(Date()) </SCRIPT>

If we use two commands, the first command is executed then the second one. This happens faster than the eye can see. It is important to understand that an ordered sequence of commands we write is executed in the order we designed. We can control a sequence of events which is repeated by anyone who happens to run the program, or in the case of JavaScript, by anyone who looks at our Web page.

    This example has two commands to display the date this page was last modified, and today's date:

    <SCRIPT LANGUAGE="JavaScript">

    document.write(document.lastModified)

    document.write(" ", Date())

    </SCRIPT>

    JavaScript Statement Rules

    A single JavaScript statement can span one or more lines. If many statements are put on the same line, they must be seperated by a semi-colon ;

    JavaScript is case sensitive, this means that an upper case character is not the same as a lower case character: www is not the same as wWw or WWW.

The following link explains the JavaScript statements.

[Contents] [Tutorial] [Object Hierrachy] [Language] [Expressions] [Statements]

  Copyright 2000 J3 Ltd Permission is granted to reproduce material on this page, on the condition that a reference to "WWW.J3Ltd.com" is given as the source of the material.