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.


Almost everything in JavaScript is either an object or a property of an object. In many cases even the properties of objects are themselves objects. JavaScript has a number of objects available in the core language as well as many more for interfacing with the browser and document. Once you get past the basics of […]


If you have a lot of code inside of your loop then you may end up with if statements nested several levels deep making the code really complicated to follow where you need to skip over the rest of the code and start the next iteration of the loop when a particular condition applies. Generally […]

Loop Break

Just occassionally the conditions we need to test in order to determine whether or not to continue running a loop can become so complicated that the condition test itself becomes hard to read. When this happens we can make our code easier to read by moving some of the conditions into if statements inside the […]

Do While Loop

The third type of loop in JavaScript is the do while loop. A do while loop is similar to a while loop but instead of testing the condition at the start of the loop it tests the condition at the end. The code in a do while loop will always be run at least once.

While Loop

The second type of loop in JavaScript is the while loop. Instead of specifying three values to control the loop as we have when we use a for loop, the while loop simply tests a condition in the same way that an if statement does with the difference being that an if statement only runs […]

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

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.