11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table 21-4: Proprietary Extensions to JScript in Version 3.0<br />

Feature Description<br />

chapter.<br />

VBArray object Permits <strong>JavaScript</strong> to use ―safe‖ VBScript arrays.<br />

Conditional<br />

compilation<br />

JScript 4.0<br />

Allows dynamic definition and execution of code (rather than<br />

linear runtime ―compilation‖). This feature is described in more<br />

detail later in the chapter.<br />

This language version was never included as part of a browser release. Rather, it was included<br />

in Microsoft Visual Studio. However, JScript 4.0 is for all intents and purposes the same as<br />

JScript 3.0, just repackaged and renamed for inclusion with another application.<br />

JScript 5.0<br />

Version 5.0 of JScript marks the beginning of support for advanced exception handling.<br />

Included is the try/catch construct discussed in Chapter 23, the Error object, and the throw<br />

statement for generating custom error conditions. <strong>The</strong> only other major additions in this version<br />

are the for/in loop for iterating over object properties and the instanceof operator.<br />

JScript 5.5<br />

JScript 5.5 corresponds closely to <strong>JavaScript</strong> 1.5 and is in compliance with ECMAScript Edition<br />

3. <strong>The</strong> new features are listed here:<br />

Improvements to functions, including the implicitly filled callee property, as well as the<br />

call() and apply() methods. A length property was included with a function‘s<br />

arguments to indicate the actual number of parameters passed.<br />

<strong>The</strong> new String method charCodeAt().<br />

Global decodeURI() and encodeURI() methods, offering similar functionality to the<br />

existing escape() and unescape().<br />

Stack and Queue methods for Array: pop(), push(), shift(), and unshift(). In addition,<br />

the splice() method was also added.<br />

Various useful enhancements to regular expressions.<br />

Numerous global conversion functions, such as toExponential(), toFixed(),<br />

toPrecision(), toTimeString(), and toDateString().<br />

Proprietary JScript Features<br />

Although the core language capabilities of JScript have not strayed too far from mainstream<br />

<strong>JavaScript</strong>, Microsoft does implement a few unique features. Some features like collections<br />

have been a widely used part of the language for quite some time and have even been adopted<br />

into Web standards.<br />

Targeting Internet Explorer<br />

Since the features discussed in this section are specific to Internet Explorer, it makes sense to<br />

hide them from other browsers. <strong>The</strong> easiest way to do this is with the language and type<br />

attributes of the tag. IE recognizes ―JScript‖ as a valid language value, and<br />

―text/jscript‖ as a valid type value. Other browsers do not, and will therefore ignore the contents<br />

of such a script. So, when writing IE-specific scripts, you might use<br />

<br />

// IE-specific <strong>JavaScript</strong><br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!