Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 611365 of New in JavaScript 1.5

  • Revision slug: Web/JavaScript/New_in_JavaScript/1.5
  • Revision title: New in JavaScript 1.5
  • Revision id: 611365
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment JavaScript/New_in_JavaScript/1.5 Web/JavaScript/New_in_JavaScript/1.5

Revision Content

JavaScript version 1.5 provides new features and enhancements described below.

Runtime errors

Runtime errors are now reported as exceptions.

Number formatting enhancements

Number formatting has been enhanced to include Number.prototype.toExponential, Number.prototype.toFixed, and Number.prototype.toPrecision methods. See the Number Object page.

Regular expression enhancements

The following regular expression enhancements have been added:

  • Quantifiers — +, *, ? and {} — can now be followed by a ? to force them to be non-greedy. See the entry for ? on the Writing a Regular Expression Pattern page.
  • Non-capturing parentheses, (?:x) can be used instead of capturing parentheses, (x). When non-capturing parentheses are used, matched subexpressions are not available as back-references. See the entry for (?:x) on the Writing a Regular Expression Pattern page.
  • Positive and negative lookahead assertions are supported. Both assert a match depending on what follows the string being matched. See the entries for x(?=y) and x(?!y) on the Writing a Regular Expression Pattern page.
  • The m flag has been added to specify that the regular expression should match over multiple lines. See the Advanced Searching With Flags page.

Conditional function declarations

Functions can now be declared inside an if clause. See the Defining Functions page.

Function expressions

Functions can now be declared inside an expression. See the Defining Functions page.

Multiple catch clauses

Multiple catch clauses in a try...catch statement are supported. See The catch Block page.

Getters and setters

JavaScript writers can now add getters and setters to their objects. This feature is available only in the C implementation of JavaScript. See the Defining Getters and Setters page.

Constants

Read-only named constants are supported. This feature is available only in the C implementation of JavaScript. See the Constants page.

Revision Source

<p>JavaScript version 1.5 provides new features and enhancements described below.</p>

<h2 id="Runtime_errors">Runtime errors</h2>
<p>Runtime errors are now reported as exceptions.</p>

<h2 id="Number_formatting_enhancements">Number formatting enhancements</h2>
<p>Number formatting has been enhanced to include <code>Number.prototype.toExponential</code>, <code>Number.prototype.toFixed</code>, and <code>Number.prototype.toPrecision</code> methods. See the <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Predefined_Core_Objects/Number_Object" title="JavaScript/Guide/Obsolete_Pages/Predefined_Core_Objects/Number_Object">Number Object</a> page.</p>

<h2 id="Regular_expression_enhancements">Regular expression enhancements</h2>
<p>The following regular expression enhancements have been added:</p>
<ul>
  <li>Quantifiers — +, *, ? and {} — can now be followed by a ? to force them to be non-greedy. See the entry for ? on the <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Writing_a_Regular_Expression_Pattern#Using_Special_Characters" title="JavaScript/Guide/Obsolete_Pages/Writing_a_Regular_Expression_Pattern#Using_Special_Characters">Writing a Regular Expression Pattern</a> page.</li>
  <li>Non-capturing parentheses, (?:x) can be used instead of capturing parentheses, (x). When non-capturing parentheses are used, matched subexpressions are not available as back-references. See the entry for (?:x) on the <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Writing_a_Regular_Expression_Pattern#Using_Special_Characters" title="JavaScript/Guide/Obsolete_Pages/Writing_a_Regular_Expression_Pattern#Using_Special_Characters">Writing a Regular Expression Pattern</a> page.</li>
  <li>Positive and negative lookahead assertions are supported. Both assert a match depending on what follows the string being matched. See the entries for x(?=y) and x(?!y) on the <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Writing_a_Regular_Expression_Pattern#Using_Special_Characters" title="JavaScript/Guide/Obsolete_Pages/Writing_a_Regular_Expression_Pattern#Using_Special_Characters">Writing a Regular Expression Pattern</a> page.</li>
  <li>The m flag has been added to specify that the regular expression should match over multiple lines. See the <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Working_with_Regular_Expressions/Advanced_Searching_With_Flags" title="JavaScript/Guide/Obsolete_Pages/Working_with_Regular_Expressions/Advanced_Searching_With_Flags">Advanced Searching With Flags</a> page.</li>
</ul>

<h2 id="Conditional_function_declarations">Conditional function declarations</h2>
<p>Functions can now be declared inside an if clause. See the <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Defining_Functions" title="JavaScript/Guide/Obsolete_Pages/Defining_Functions">Defining Functions</a> page.</p>
<h2 id="Function_expressions">Function expressions</h2>
<p>Functions can now be declared inside an expression. See the <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Defining_Functions" title="JavaScript/Guide/Obsolete_Pages/Defining_Functions">Defining Functions</a> page.</p>

<h2 id="Multiple_catch_clauses">Multiple catch clauses</h2>
<p>Multiple catch clauses in a try...catch statement are supported. See <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Exception_Handling_Statements/try...catch_Statement#The_catch_Block" title="JavaScript/Guide/Obsolete_Pages/Exception_Handling_Statements/try...catch_Statement#The_catch_Block">The catch Block</a> page.</p>
<h2 id="Getters_and_setters">Getters and setters</h2>
<p>JavaScript writers can now add getters and setters to their objects. This feature is available only in the C implementation of JavaScript. See the <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Creating_New_Objects/Defining_Getters_and_Setters" title="JavaScript/Guide/Obsolete_Pages/Creating_New_Objects/Defining_Getters_and_Setters">Defining Getters and Setters</a> page.</p>

<h2 id="Constants">Constants</h2>
<p>Read-only named constants are supported. This feature is available only in the C implementation of JavaScript. See the <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Constants" title="JavaScript/Guide/Obsolete_Pages/Constants">Constants</a> page.</p>
Revert to this revision