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 ECMAScript5.1 in 2011 have been added (if I have missed any please let me know). Those commands introduced in ECMAScript2015 are currently being added (there are lots of them so it may take some time but then most current browsers do not yet support them all anyway). 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.

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.


While setTimeout waits for a specified period of time and then adds a new function onto the queue of code to be run (where hopefully it will not be delayed too much by any currently running process – since only one JavaScript process can run at a time), setInterval adds a function to the queue […]


Most JavaScript commands run one after the other as a part of the same process. Your JavaScript code generally consists of a number of processes, one of which may run immediately the page finishes loading, with the rest mostly running when triggered by specific events. There are a few commands though that run asynchronously – […]

encodeURI and decodeURI

JavaScript is often used to insert values into the querystring on the end of a web address and sometimes used to store information in cookies. Where either of these tasks is performed there are specific values that have reserved meanings in the text strings you need to produce and you need to “escape” those characters […]


By using exponential notation internally and limiting the precision of the numbers to fifteen digits, JavaScript can hold approximations of numbers that are extremely large. It does have an upper limit though and if the number gets too big it will eventiually be replaced by a special value that indicates that the number is too […]


Not everything can be converted into a number and JavaScript contains a special value that it uses as the result when you try to convert something that isn’t a number into one. The isNaN function allows you to easily test if a number field contains this special value that indicates that the value contained is […]

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

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.