New in JavaScript 1.6

  • Revision slug: JavaScript/New_in_JavaScript/1.6
  • Revision title: New in JavaScript 1.6
  • Revision id: 72637
  • Created:
  • Creator: Dria
  • Is current revision? No
  • Comment /* Array extras */

Revision Content

E4X

ECMAScript for XML (E4X) is a powerful technology for creating and processing XML content within JavaScript. We're going to continue to improve our E4X support, including adding transparent integration with the existing DOM, but developers who are building XML-based web applications can benefit from E4X support in Firefox 1.5.

Array extras

There are seven new Array methods that can be separated into two categories, item location methods and iterative methods. The item location methods are:

  • indexOf() - returns the index of the given item's first occurrence.
  • lastIndexOf() - returns the index of the given item's last occurrence.

The iterative methods are:

  • every() - runs a function on every item in the array and returns true if the function returns true for every item.
  • filter() - runs a function on every item in the array and returns an array of all items for which the function returns true.
  • forEach() - runs a function on every item in the array.
  • map() - runs a function on every item in the array and returns the results in an array.
  • some() - runs a function on every item in the array and returns true if the function returns true for any one item.

For more information, see Nicholas C. Zakas' article, Mozilla's New Array Methods.

Array and String generics

Revision Source

<p>
</p>
<h3 name="E4X"> E4X </h3>
<p>ECMAScript for XML (<a href="Special:Tags?tag=E4X&amp;language=en">E4X</a>) is a powerful technology for creating and processing <a href="en/XML">XML</a> content within <a href="en/JavaScript">JavaScript</a>.  We're going to continue to improve our E4X support, including adding transparent integration with the existing <a href="en/DOM">DOM</a>, but developers who are building XML-based web applications can benefit from E4X support in Firefox 1.5.
</p>
<h3 name="Array_extras"> Array extras </h3>
<p>There are seven new <code><a href="en/Core_JavaScript_1.5_Reference/Objects/Array">Array</a></code> methods that can be separated into two categories, item location methods and iterative methods. The item location methods are:
</p>
<ul><li> <code><a href="en/Core_JavaScript_1.5_Reference/Objects/Array/indexOf">indexOf()</a></code> - returns the index of the given item's first occurrence.
</li><li> <code><a href="en/Core_JavaScript_1.5_Reference/Objects/Array/lastIndexOf">lastIndexOf()</a></code> - returns the index of the given item's last occurrence.
</li></ul>
<p>The iterative methods are:
</p>
<ul><li> <code><a href="en/Core_JavaScript_1.5_Reference/Objects/Array/every">every()</a></code> - runs a function on every item in the array and returns true if the function returns true for every item.
</li><li> <code><a href="en/Core_JavaScript_1.5_Reference/Objects/Array/filter">filter()</a></code> - runs a function on every item in the array and returns an array of all items for which the function returns true.
</li><li> <code><a href="en/Core_JavaScript_1.5_Reference/Objects/Array/forEach">forEach()</a></code> - runs a function on every item in the array.
</li><li> <code><a href="en/Core_JavaScript_1.5_Reference/Objects/Array/map">map()</a></code> - runs a function on every item in the array and returns the results in an array.
</li><li> <code><a href="en/Core_JavaScript_1.5_Reference/Objects/Array/some">some()</a></code> - runs a function on every item in the array and returns true if the function returns true for any one item.
</li></ul>
<p>For more information, see Nicholas C. Zakas' article, <span class="exlink"><a href="en/Mozilla's_New_Array_Methods_(external)">Mozilla's New Array Methods</a></span>.
</p>
<h3 name="Array_and_String_generics"> Array and String generics </h3>
Revert to this revision