In 1995 a programmer called Brendan Eich joined Netscape Communications.
Netscape “was looking for someone to work on a scripting language or some kind of language inside the browser that could be used to automate parts of a web page or make a web page more dynamic”, wrote Eich in an article on Netscape’s website.
The language was initially called Mocha, then Livescript, and finally Javascript, in a deliberate attempt to ride the waves of Java’s success.
The name still causes confusion, since Javascript is completely different from Java. Microsoft attempted to derail it with VBscript, but this was not implemented by browsers other than Internet Explorer, making Javascript the only choice for scripting web pages.
Javascript was standardised by ECMA, a European standards body, and the official specification is called ECMAscript. Microsoft’s implementation is called Jscript, while Adobe has a version running in Flash called Actionscript.
Javascript is widely used, but not really loved. There are many compatibility issues, mainly with the document object model presented by different browsers. Javascript developers have to learn tricks to get code working everywhere. These issues, combined with the perception that Javascript is only for scripting, meant that few developers attempted to use Javascript for substantial applications.
This is changing and Javascript usage is growing fast. The first key factor is the rise of Ajax, where web applications have extensive client-side script to give users a richer, more seamless user interface.
The second factor is the use of Flash for applications beyond multimedia effects. Adobe’s Flex product, soon to be joined by a related project called Apollo, lets you code for Flash with XML and Actionscript, which is easier for developers than the designer-oriented Flash IDE.
Object orientation
Javascript has long supported object oriented programming, although if you only
use it for scripting web pages, you might not have explored this part of the
language. Javascript is a dynamic language, allowing a free and easy approach
where properties are created on the fly. For example, if you were writing code
to manage a magazine archive, you might have something such as this:
mag = new Object();
mag.name = "PCW";
someLabel.innerHTML = "The magazine name is: " + mag2.name;
This code creates a new object, adds a property on the fly, and then references it. You can even add methods in similar style:
function describe()
{
return "The magazine name is: " + this.name;
}
mag = new Object();
mag.name = "PCW";
mag.getdescription = describe;
someLabel.innerHTML = mag2.getdescription();
All OnlineTags: Visual Programming
