Southend Linux User Group

Javascript language structure

Javascript – the language structure

ECMAScript, or as its more popularly known, Javascript, is the scripting language standardized by Ecma International specification ECMA-262 and ISO/IEC 16262. The language is widely used for client-side scripting on the web. Javascript consists of of a set of commands and their syntax. Similar to the rules of grammar, the syntax is simply the way the commands are written so the machine compiler (or interpreter can understand what you have written).

In 1960 it was decided that an association of manufacturers should be formed which would be called European Computer Manufacturers Association (abbreviated to ECMA), By 1994, the global activities of the Europe-based Ecma organization resulted in a name change to, Ecma International – European association for standardizing information and communication systems.

When you start writing programs you will make a lot of mistakes, until you become familiar with the syntax. These typographical errors, or bugs, will in general be picked up by the compiler (or interpreter) when you run your program. They must be corrected before the program will run. Until you become comfortable with the syntax this can be very frustrating but it is part of the learning process and there are no short cuts. It is just a question of practice.

All procedural programs can be written using three basic constructs which should already be familiar to you, if you have used flow charts or (Jackson) structure diagrams. These are,

  • sequence
  • selection (conditional or decision statements)
  • iteration. ( also called repetition or loop)

When looking at program code keep these simple structures in mind. Initially it is a good idea to practice by writing a short program to exercise an unfamiliar command in order to find out what it does. Make plenty of use of the on line help. Very often there are examples associated with the various commands that will help you get started.

The order in which you learn the commands is not important, but as a general rule the first things you need to be able to do is output data from your program. It is traditional that the first program you write is called Hello world. It does nothing more than greet you when the program is run.

Most programmers start by taking bits from other programs and joining them together to create new programs. The examples provided demonstrate some of the various things that you can do. Do the examples, to get practice at debugging. Compare what the program does with the code as this is the easiest way to understand what is going on. To gain confidence, experiment by making slight changes of your own. Don’t be afraid of making mistakes, you will learn from them.

Is Javascript an Object oriented language?

Javascript is not an object- oriented language, because it has no class constructor. Rather it creates object instances, borrowing the notions of object properties and methods.

In Objected Orientated languages, such as C++ or Java, class is an abstraction. For example student may be a class while a particular student is said to be an instance of that class. javascript simply deals with instances, however this does not stop programmers trying to layer in the concepts of class structures such as sub classes and inheritance.

The properties and methods of an object are accessed using the dot notation. The brackets distinguish a method from a property. Understanding how Javascript accesses the HTML tags on a web page is crucial.

Javascript has a number of built-in objects so as well as getting to grips with the syntax of the language, learning how to use these objects effectively is also at the heart of program development.


objectName.methodName(optional arguments)

Author: Alan Campion - Page reference: 4351
Last modified: Alan Campion - 2015-02-08