mozilla

Revision 329707 of New in JavaScript 1.8.5

  • Revision slug: JavaScript/New_in_JavaScript/1.8.5
  • Revision title: New in JavaScript 1.8.5
  • Revision id: 329707
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment CleanUp.

Revision Content

{{gecko_minversion_header("2.0")}}

JavaScript 1.8.5 is the version of JavaScript included in Firefox 4.

New functions

Function Description
Object.create Creates a new object with the specified prototype object and properties. {{bug("492840")}}
Object.defineProperty Adds the named property described by a given descriptor to an object.
Object.defineProperties Adds the named properties described by the given descriptors to an object.
Object.getOwnPropertyDescriptor Returns a property descriptor for a named property on an object. {{bug("505587")}}
Object.keys Returns an array of all enumerable properties on an object. {{bug("307791")}}
Object.getOwnPropertyNames Returns an array of all enumerable and non-enumerable properties on an object. {{bug("518663")}}
Object.preventExtensions Prevents any extensions of an object. {{bug("492849")}}
Object.isExtensible Determine if extending of an object is allowed. {{bug("492849")}}
Object.seal Prevents other code from deleting properties of an object. {{bug("492845")}}
Object.isSealed Determine if an object is sealed. {{bug("492845")}}
Object.freeze Freezes an object: other code can't delete or change any properties. {{bug("492844")}}
Object.isFrozen Determine if an object was frozen. {{bug("492844")}}
Array.isArray Checks if a variable is an array. {{bug("510537")}}
Date.toJSON Returns a JSON format string for a Date object.
Function.prototype.bind Creates a new function that, when called, itself calls this function in the context provided (with a given sequence of arguments) {{bug("429507")}}

New ECMAScript5 features

  • get and set operators now allows the identifier to be numeric or a string. {{bug("520696")}}
  • Function.apply() can accept any array-like object as the arguments list, instead of only true arrays.
  • strict mode support
  • Array.toString() now works even on non-arrays by either returning the result of calling its join() method if one is available or by calling its toString() method.

Other standardization work

Various non-standard syntaxes for defining getters and setters have been removed; ECMAScript 5 defined syntax has not been changed. These were all pretty esoteric and rarely used; if this affects you, see this blog post for details.

New objects

Object Description
Proxy Offers support for creating Object and Function proxies that enable meta-programming in JavaScript.

Changes to global objects

ISO 8601 support in Date
The Date object's parse() method now supports simple ISO 8601 format date strings.
Global objects made read only
The NaN, Infinity, and undefined global objects have been made read only, per the ECMAScript 5 specification.

Additional changes

JavaScript (SpiderMonkey) API changes

Note: Locale callbacks (as specified in the JSLocaleCallbacks structure) should not free the memory buffer passed to them; this buffer is managed by the SpiderMonkey runtime.

The JS_NewString() function was removed in SpiderMonkey 1.8.5. Use JS_NewStringCopyN() instead.

Revision Source

<p>{{gecko_minversion_header("2.0")}}</p>
<p>JavaScript 1.8.5 is the version of JavaScript included in Firefox 4.</p>
<h2 id="New_functions">New functions</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Function</th>
      <th scope="col">Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/create" title="JavaScript/Reference/Global Objects/Object/Create">Object.create</a></code></td>
      <td>Creates a new object with the specified prototype object and properties. {{bug("492840")}}</td>
    </tr>
    <tr>
      <td><code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty" title="JavaScript/Reference/Global Objects/Object/DefineProperty">Object.defineProperty</a></code></td>
      <td>Adds the named property described by a given descriptor to an object.</td>
    </tr>
    <tr>
      <td><code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperties" title="JavaScript/Reference/Global Objects/Object/DefineProperties">Object.defineProperties</a></code></td>
      <td>Adds the named properties described by the given descriptors to an object.</td>
    </tr>
    <tr>
      <td><code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor" title="JavaScript/Reference/Global Objects/Object/GetOwnPropertyDescriptor">Object.getOwnPropertyDescriptor</a></code></td>
      <td>Returns a property descriptor for a named property on an object. {{bug("505587")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys" title="JavaScript/Reference/Global Objects/Object/keys"><code>Object.keys</code></a></td>
      <td>Returns an array of all enumerable properties on an object. {{bug("307791")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames" title="JavaScript/Reference/Global Objects/Object/getOwnPropertyNames"><code>Object.getOwnPropertyNames </code></a></td>
      <td>Returns an array of all enumerable and non-enumerable properties on an object. {{bug("518663")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/preventExtensions" title="JavaScript/Reference/Global Objects/Object/preventExtensions"><code>Object.preventExtensions</code></a></td>
      <td>Prevents any extensions of an object. {{bug("492849")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/isExtensible" title="JavaScript/Reference/Global Objects/Object/isExtensible"><code>Object.isExtensible</code></a></td>
      <td>Determine if extending of an object is allowed. {{bug("492849")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/seal" title="JavaScript/Reference/Global Objects/Object/seal"><code>Object.seal</code></a></td>
      <td>Prevents other code from deleting properties of an object. {{bug("492845")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/isSealed" title="JavaScript/Reference/Global Objects/Object/isSealed"><code>Object.isSealed</code></a></td>
      <td>Determine if an object is sealed. {{bug("492845")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/freeze" title="JavaScript/Reference/Global Objects/Object/freezed"><code>Object.freeze</code></a></td>
      <td>Freezes an object: other code can't delete or change any properties. {{bug("492844")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/isFrozen" title="JavaScript/Reference/Global Objects/Object/isFrozen"><code>Object.isFrozen</code></a></td>
      <td>Determine if an object was frozen. {{bug("492844")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Array/isArray" title="JavaScript/Reference/Global Objects/Array/isArray"><code>Array.isArray </code></a></td>
      <td>Checks if a variable is an array. {{bug("510537")}}</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date/toJSON" title="JavaScript/Reference/Global Objects/Date/toJSON"><code>Date.toJSON</code></a></td>
      <td>Returns a JSON format string for a <code>Date</code> object.</td>
    </tr>
    <tr>
      <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind" title="JavaScript/Reference/Global_Objects/Function/bind"><code>Function.prototype.bind</code></a></td>
      <td>Creates a new function that, when called, itself calls this function in the context provided (with a given sequence of arguments) {{bug("429507")}}</td>
    </tr>
  </tbody>
</table>
<h2 id="New_ECMAScript5_features">New ECMAScript5 features</h2>
<ul>
  <li><code><a href="/en-US/docs/JavaScript/Reference/Operators/get" title="JavaScript/Reference/Operators/Special Operators/get Operator">get</a></code> and <code><a href="/en-US/docs/JavaScript/Reference/Operators/set" title="JavaScript/Reference/Operators/Special Operators/set Operator">set</a></code> operators now allows the identifier to be numeric or a string. {{bug("520696")}}</li>
  <li><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply" title="JavaScript/Reference/Global Objects/Function/apply"><code>Function.apply()</code></a> can accept any array-like object as the arguments list, instead of only true arrays.</li>
  <li><a href="/en-US/docs/JavaScript/Reference/Functions_and_function_scope/Strict_mode" title="JavaScript/Strict mode">strict mode support</a></li>
  <li><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Array/toString" title="JavaScript/Reference/Global Objects/Array/toString"><code>Array.toString()</code></a> now works even on non-arrays by either returning the result of calling its <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Array/join" title="JavaScript/Reference/Global Objects/Array/join"><code>join()</code></a> method if one is available or by calling its <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/toString" title="JavaScript/Reference/Global Objects/Object/toString"><code>toString()</code></a> method.</li>
</ul>
<h2 id="Other_standardization_work">Other standardization work</h2>
<p>Various non-standard syntaxes for defining getters and setters have been removed; ECMAScript 5 defined syntax has not been changed. These were all pretty esoteric and rarely used; if this affects you, see <a class="external" href="http://whereswalden.com/2010/04/16/more-spidermonkey-changes-ancient-esoteric-very-rarely-used-syntax-for-creating-getters-and-setters-is-being-removed/" title="http://whereswalden.com/2010/04/16/more-spidermonkey-changes-ancient-esoteric-very-rarely-used-syntax-for-creating-getters-and-setters-is-being-removed/">this blog post</a> for details.</p>
<h2 id="New_objects">New objects</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Object</th>
      <th scope="col">Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Proxy" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Proxy">Proxy</a></code></td>
      <td>Offers support for creating <code>Object</code> and <code>Function</code> proxies that enable meta-programming in JavaScript.</td>
    </tr>
  </tbody>
</table>
<h2 id="Changes_to_global_objects">Changes to global objects</h2>
<dl>
  <dt>ISO 8601 support in <code>Date</code></dt>
  <dd>The <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date"><code>Date</code></a> object's <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date/parse" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse"><code>parse()</code></a> method now supports simple ISO 8601 format date strings.</dd>
  <dt>Global objects made read only</dt>
  <dd>The <a href="/en-US/docs/JavaScript/Reference/Global_Objects/NaN" title="JavaScript/Reference/Global Objects/NaN"><code>NaN</code></a>, <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Infinity" title="JavaScript/Reference/Global Objects/Infinity"><code>Infinity</code></a>, and <a href="/en-US/docs/JavaScript/Reference/Global_Objects/undefined" title="JavaScript/Reference/Global Objects/undefined"><code>undefined</code></a> global objects have been made read only, per the ECMAScript 5 specification.</dd>
</dl>
<h2 id="Additional_changes">Additional changes</h2>
<ul>
  <li><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/Parent" title="JavaScript/Reference/Global Objects/Object/Parent"><code>obj.__parent__</code></a> and <code>obj.__count__</code> become obsolete. Some information about why: <a class="external" href="http://whereswalden.com/2010/05/07/spidermonkey-change-du-jour-the-special-__parent__-property-has-been-removed/" title="http://whereswalden.com/2010/05/07/spidermonkey-change-du-jour-the-special-__parent__-property-has-been-removed/">SpiderMonkey change du jour: the special __parent__ property has been removed</a> {{bug("551529")}} &amp; {{bug("552560")}}.</li>
  <li>Trailing commas no longer accepted in <a href="/En/Using_native_JSON" title="Using native JSON"><code>JSON.parse()</code></a>.</li>
</ul>
<h2 id="JavaScript_(SpiderMonkey)_API_changes">JavaScript (SpiderMonkey) API changes</h2>
<div class="note">
  <strong>Note:</strong> Locale callbacks (as specified in the <a href="/en-US/docs/JSLocaleCallbacks" title="JSLocaleCallbacks">JSLocaleCallbacks</a> structure) should not free the memory buffer passed to them; this buffer is managed by the SpiderMonkey runtime.</div>
<p>The <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_NewString" title="SpiderMonkey/JSAPI Reference/JS NewString"><code>JS_NewString()</code></a> function was removed in SpiderMonkey 1.8.5. Use <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_NewStringCopyN" title="SpiderMonkey/JSAPI Reference/JS NewStringCopyN"><code>JS_NewStringCopyN()</code></a> instead.</p>

<!--languages( "pt":"pt/JavaScript/Novo no JavaScript/1.8.5" )-->
Revert to this revision