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.

Special Characters

Whitespace in text comes in a number of different varieties. As well as the space character there are also tab, linefeed, carriage return, form feed, vertical tab and other whitespace characters which if directly entered into our regular expression would break the Java Script. To handle these characters JavaScript provides a collection of special escape […]

Predefined Classes

As we saw a couple of examples back, a character class is a number of characters any one of which can appear at a particular spot in the pattern. Some of these character classes are so commonly needed for pattern matching that defining the class each time tthat you want to use it would make […]

Greedy and Reluctant

One of the issues with pattern matching is where different amounts of text can match the same pattern. Do we want the pattern to match as much of the text as possible or do we want it to match as little as possible so that hopefully more of the text can then also be separately […]

Repetitions

Programs would be extremely awkward to write if it wasn’t possible to create loops within the code so as to repeat the ame code a variable number of times. Regular expressions contain a similar notation for handling repetitions within a pattern so that we can specify the minimum and maximum number of times that particular […]

Character Classes

A character class is a grouping of characters any one of which can validly appear at that spot in the text and match on that part of the regular expression. By grouping characters together into a character class we can specify the pattern in fewer characters than would be needed if we were to include […]

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.