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.

Meta Characters

There are fifteen characters that have a special meaning and which need to be escaped inside an expression where we want the character to have its regular meaning. These fifteen characters are collectively known as meta characters.

Start and End

Now that we have looked at a few of the things that can be done with regular expressions it is time to start looking at the meanings of the codes that can be used within the expressions themselves. The first two special characters we will look at are those which specifically match to the start […]

Splitting Matches

Regular expressions can also be used to split a piece of text into separate sections that are then inserted into an array. All of the content between each of the matches ends up in the array with the text that matched the expression being discarded.

Replacing Matches

There are a number of things that we can do with regular expressions and we are not limited to simply determining if a piece of text does or doesn’t contain content that matches a patern. We can easily replace the text that matches with different text.

Ignore Case and Global

There are a number of single characters that can be added to the end of a regular expression that affect how the expression is processed. The two most common are ignore case and global. By adding an ‘i’ after the closing slash of the expression we allow the matching to take place without any consideration […]

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.