Introducing JavaScript

JavaScript has changed a great deal since it was first introduced but many sites still use outdated techniques. There are even lots of JavaScript tutorials on the web that show you how JavaScript should be written so that it can work in Netscape 2 rather than so that it will work in modern browsers. As a result there are many people who are writing what they think is JavaScript but where what they are producing is more suited to the 20th Century than to the 21st.

Beginners should work through all the basic examples prior to moving on to the other examples which cover separate aspects of JavaScript in more detail.

Most of the JavaScript examples here will work in IE5+, Opera7+ and all versions of Firefox, Safari and Chrome. Those commands introduced in ECMAScript 5 in 2011 are being added to the site where they are supported by the latest version of all popular browsers. Where these new commands are not supported by IE8 or IE7 that information is included in the text since those two browsers might still have to many users for you to ignore. So few people using other browsers fail to keep their browser up to date that lack of support in older versions of other browsers will not have any significant affect.

A few examples of what we can expect from EcmaScript 6 are also included in their own section so you can see the direction that JavaScript is moving in - even though it will probably be quite a while before we can use those commands.

There is a link to jsBin at the bottom right of all the pages. This site provides an easy way to test your JavaScript code online without needing to create an entire web page to run a simple test.


Perhaps the most important property that all objects in JavaScript have is the prototype property. This property is effectively the means via which JavaScript objects can inherit shared methods and static properties from other JavaScript objects.


This aspect of JavaScript sounds a lot more complex than it really is. Basically a closure in JavaScript is the mechanism that allows properties to continue to exist after the function that defines them has finished running because the value returned from that function in cludes code that still needs to be able to access […]

Getters and Setters

Keeping the properties private and using methods to access them is such an important aspect of using objects properly that JavaScript has now introduced a special notation specifically for defining getter and setter methods. Not all browsers currently in use support this notation though but this doesn’t really matter since we can still achieve the […]


With so many different ways to create objects in JavaScript it can become hard to tell whether one object actually inherits from a given “template” object. The instanceOf command can often assist us in answering this question although there are ways of creating an object from another object that make it impossible to tell that […]

The Constructor Method

Yet a third way of creating objects in JavaScript is to specify that a new object is to use the same constructor as an object that you have already defined.

This site is © copyright Stephen Chapman - Felgall Pty Ltd 2011-2014.

Privacy Policy | Terms and Conditions

You are welcome to use any the example JavaScript from this site in the scripts for your site or any that you develop for others but may not use the longer example scripts that contain a copyright notice in any other way without permission.