ECMAScript
From Wikipedia, the free encyclopedia
ECMAScript is a scripting programming language, standardized by Ecma International in the ECMA-262 specification. The language is widely used on the web, and is often referred to as JavaScript or JScript, although those two languages are extensions of the ECMA-262 standard.
Contents |
[edit] History
In December 1995 Sun Microsystems and Netscape Communications Corporation introduced [1] JavaScript. In March 1996 Netscape Communications Corporation released Netscape Navigator 2.0, which featured support for JavaScript. Due to the de facto success of JavaScript as a client-side scripting language for web pages, Microsoft developed a "roughly" compatible language known as JScript, which was included in Internet Explorer 3.0, released in August 1996.
Netscape submitted the JavaScript specification to Ecma International for standardization; the work on the specification, ECMA-262, began in November 1996. The first edition of ECMA-262 was adopted by the ECMA General Assembly of June 1997.
ECMAScript is the name of the scripting language standardized in ECMA-262. Both JavaScript and JScript technologies aim to be compatible with ECMAScript, while providing additional features not described in the ECMA specification.
[edit] Versions
There are three editions of ECMA-262 published, and the work on the fourth edition is in progress.
| Edition | Date published | Differences to the previous edition |
|---|---|---|
| 1 | June 1997 | First edition |
| 2 | June 1998 | Editorial changes to keep the specification fully aligned with ISO/IEC 16262 international standard. |
| 3 | December 1999 | Powerful regular expressions, better string handling, new control statements, try/catch exception handling, tighter definition of errors, formatting for numeric output and other. |
| 4 | Work in progress | Maybe explicit class definitions, packages and namespaces, optional static typing, better exposure of previously internal features (properties, key enumerability), and more? |
In June 2004 Ecma International published ECMA-357 standard, defining an extension to ECMAScript, known as E4X (ECMAScript for XML).
[edit] Dialects
ECMAScript is supported in many applications, especially web browsers, where it's commonly called JavaScript. Dialects typically include their own, different standard libraries, of which some are standardized separately – such as the W3C-specified DOM. Some implementations, such as ActionScript used in Flash, have a completely different set of libraries. This means that applications written in one dialect of ECMAScript will not likely work in another, unless they are designed to be compatible.
| Application | Dialect | Latest dialect version | Corresponding ECMAScript edition |
|---|---|---|---|
| Gecko-based browsers and other programs embedding SpiderMonkey, including Mozilla Firefox | JavaScript | 1.7 | ECMA-262, edition 3 1 |
| Internet Explorer | JScript | 5.6 | ECMA-262, edition 3 |
| Opera | ECMAScript, with extensions to both JavaScript and JScript | 1.3/1.5 | ECMA-262, edition 3 |
| KHTML based browsers, including KDE's Konqueror | JavaScript | 1.5 | ECMA-262 |
| Microsoft .NET Framework | JScript .NET | 8.0 | ECMA-262, edition 3 2 |
| Adobe Flash | ActionScript | 2
3 | ECMA-262, edition 3 3
ECMA-262, edition 4 4 |
| Adobe Acrobat | JavaScript | 1.5 | ECMA-262, edition 3 |
| General purpose scripting language | DMDScript | 1.06 | ECMA-262 |
| OpenLaszlo Platform | JavaScript | 1.4 | ECMA-262, edition 3 5 |
| iCab | InScript | 3.22 | ECMA-262, edition 3 |
| Implements XML in Gecko-based browsers and programs embedding SpiderMonkey | E4X | ??? | ECMA-357, edition 2 |
Note (1): Gecko 1.8.1 has partial support of E4X [2] and a few other features, see New in JavaScript 1.7.
Note (2): Microsoft claims that JScript 8.0 supports "almost all of the features of the ECMAScript Edition 3 Language Specification" but does not list the unsupported features.
Note (3): In addition to supporting ECMA-262 edition 3, ActionScript 2 also included support of properties, methods, and mechanisms that were proposed in early draft specifications of as yet unseen versions of ECMAScript. It remains to be seen if ActionScript will stay in sync with future changes to the ECMAScript specifications.
Note (4): As claimed by Adobe, it implements the preliminary edition 4 of ECMA-262 [3]
Note (5): As stated by OpenLaszlo, it partially implements edition 3 of ECMA-262 [4]
The Mozilla implementations, (SpiderMonkey in the C programming language and Rhino in the Java programming language), are used in several third-party programs, including the Yahoo! Widget Engine (Konfabulator) and the Macintosh system-level scripting language JavaScript OSA.
Apple's Safari uses JavaScriptCore which is based on the KDE KJS library.
[edit] Version correspondence
The following table is based on [5] and [6]; items on the same line are approximately the same language.
| JavaScript | JScript | ECMAScript |
|---|---|---|
| 1.0 (Netscape 2.0, Mar 1996) | 1.0 (IE 3.0 - early versions, Aug 1996) | |
| 1.1 (Netscape 3.0, Aug 1996) | 2.0 (IE 3.0 - later versions, Jan 1997) | |
| 1.2 (Netscape 4.0, Jun 1997) | ||
| 1.3 (Netscape 4.5, Oct 1998) | 3.0 (IE 4.0, Oct 1997) | edition 1 (June 1997) / edition 2 (June 1998) |
| 1.4 (Netscape Server only) | 4.0 (Visual Studio 6, no IE release) | |
| 5.0 (IE 5.0, Mar 1999) | ||
| 5.1 (IE 5.01) | ||
| 1.5 (Netscape 6.0, Nov 2000; also later Netscape and Mozilla releases) | 5.5 (IE 5.5, Jul 2000) | edition 3 (Dec 1999) |
| 5.6 (IE 6.0, Oct 2001) | ||
| 1.6 (Gecko 1.8, Firefox 1.5, November 2005) | edition 3, with some compliant enhancements: E4X, Array extras (e.g. Array.prototype.forEach), Array and String generics [7]
| |
| 1.7 (Gecko 1.8.1, Firefox 2.0, Fall 2006), an extension of JavaScript 1.6 (under development) | edition 3 plus all JavaScript 1.6 enhancements, plus Pythonic generators and array comprehensions ([a*a for (a in iter)]), block scope with let, destructuring assignment (var [a,b]=[1,2]) [8]
| |
| JScript .NET (ASP.NET; no IE release) | (JScript .NET is said to be designed with the participation of other ECMA members) | |
| JavaScript 2.0 (an old "Netscape proposal") | edition 4 (work in progress) |
[edit] Fourth edition
The current work on the fourth edition of ECMAScript has received some criticism, as there is thought to be a concerted effort by the organization to change the language from a prototype-based programming language into a more traditional class-based programming one, in essence, changing the very nature of how JavaScript treats relationships between objects. JavaScript is often championed by prototype-based language advocates, as it is the best known language with this object-oriented feature. ActionScript version 2.0 is an example of a ECMAScript implementation which is already more class-based than prototype-based. It will be formally defined in terms of Standard ML of New Jersey, a member of the ML programming language family[9]; ML offers strong support for many desired or proposed features such as tail recursion.[10]
It is also noted that the fourth edition has been very long awaited. The third edition was released in 1999, since that time, interactive web applications have grown tremendously in complexity, while the scripting language has remained essentially frozen.
[edit] ECMAScript variables
Variables in ECMAScript are defined by using the var operator (short for variable), followed by the variable name, such as:
var test = "hi";
In this example, the variable test is declared and given an initialization value of "hi" (a string). Because ECMAScript is dynamically typed, the interpreter automatically creates a string value for test without any explicit type declaration. You can also define two or more variables using the same var statement:
var test = "hi", test2 = "hola";
The previous code defines the variable test to have a value of "hi" and the variable test2 to have a value of "hola". Variables using the same var statement don’t have to be of the same type, however, as shown in the following:
var test = "hi", age = 25;
This example defines test (yet again) in addition to another variable named age that is set to the value of 25. Even though test and age are two different data types, this is perfectly legal in ECMAScript. Unlike Java, variables in ECMAScript do not require initialization (they are actually initialized behind the scene). Therefore, this line of code is valid:
var test;
Also unlike Java, variables can hold different types of values at different times; this is the advantage of loosely typed variables. A variable can be initialized with a string value, for instance, and later on be set to a number value, like this:
var test = 'hi'; alert(test); //outputs 'hi' //do something else here test = 55; alert(test); //outputs '55'
This code outputs both the string and the number values without incident (or error). As mentioned previously, it is best coding practice for a variable to always contain a value of the same type throughout its use.
[edit] See also
[edit] External links
- Standard ECMA-262 ECMAScript Language Specification 3rd edition (December 1999)
- Standard ECMA-290 ECMAScript Components Specification (June 1999)
- Standard ECMA-327 ECMAScript 3rd Edition Compact Profile (June 2001)
- Standard ECMA-357 ECMAScript for XML (E4X) Specification (June 2004)
- Export Root of the ECMAScript 4 Committee Wikide:ECMAScript
da:ECMAScript es:ECMAScript ko:ECMA스크립트 hu:ECMAScript ja:ECMAScript no:ECMAScript pl:ECMAScript pt:ECMAScript ru:ECMAScript sv:ECMAScript zh:ECMAScript
Categories: Cleanup from November 2006 | C programming language family | Curly bracket programming languages | Domain-specific programming languages | JavaScript dialect engines | JavaScript programming language family | Object-based programming languages | Prototype-based programming languages | ISO standards | Scripting languages

