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.

Call and Apply

JavaScript allows any function or method defined in your code to be “borrowed” by any object that you want to use it with. The call and apply methods provide a mechanism for making such a call where the code you are calling is not a method of the object as if it were a method […]

Comparing Objects

Just as passing objects works by reference rather than value, comparing objects also works by reference and two objects will only be considered to be identically equal if in fact both names refer to the exact same object. To compare objects by value you would need to perform the comparison separately for each and every […]

Object Copy

Should we need to pass an object by value rather than by reference we will need to create the copy of the object ourselves. Here we look at how to perform such a copy regardless of what the object to be copied might contain.

Passing Objects

In JavaScript, objects are passed by reference and so any updates done within the code that an object is passed to will be reflected in the values held in the original object.

Chaining Methods

Moving on from the various ways that objects can be defined in JavaScript to how they can be used. It can be extremely useful with JavaScript methods where the method doesn’t have a specific value to return for the method to return the object that it belongs to. This makes it possible to chain methods […]

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.