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+ (provided you use a deprecated MIME type - otherwise IE9 through 11 only), Opera7+ and all versions of Firefox, Safari, Vivaldi 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 and ECMAScript2016 are currently being added (there are lots of them for 2015 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 that information is included in the text - just in case you still have lots of people using that long unsupported browser. So few people using other browsers fail to keep their browser up to date that lack of support in older versions of other browsers should 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.

Not Supported

There are a lot of different programming languages that support the use of regular expressions and most of the codes used to create the patterns within the regular expressions are identical across all of the different languages so that if you have a regular expression that works in one language then it will most likely […]

Multiline Mode

The ignore and global flags might be the ones most commonly used with regular expressions but they are not the only flags that JavaScript supports. The multiline mode flag can be used with regular expressions that are being used to match to text that considst of more than one line of content in order to […]

Back Matches

While back references allow you to refer back to parts of the expression from within the replacement text, back matches allows you to reference them from later within the expression itself.

Function Replacements

You can use a function in place of the replacement text for a replace expression and pass all the captured groups into that function for further processing.


Capturing groups for use with back references becomes more complicated when you consider that the group that you want to capture may only be a part of the pattern that you want to match. In fact we don’t even need to explicitly define a group in order for this complexity to apply as the entire […]

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

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.