Home
Developers

Developers

  • Documentation
    • Developer Guide
    • API Reference
    • Style Guide
    • How-To
    • Troubleshooting
  • Submit a Flake
  • Support

Pageflakes API Reference

  • Flake System Object
  • Flake User Object
  • Pageflakes Functions
  • Array Extensions
  • String Extensions
  • ContentProxy
  • App
  • RSS
  • Tooltip Manager
  • Public, Shared, and Private Pages
  • Server-Side Scripting
Home » Documentation » API Reference

Array Extensions

The Pageflake framework modifies the Array object prototype to provide several utility functions.

Array.add(item)

Adds the item to the end of the array.

Array.removeAt(index)

Removes the item at the specified position.

Array.indexOf(item)

Searches the array for the passed item and returns the
first index where the item is found. If the item is not found, -1 is returned.

Array.remove(item)

Searches the array for the passed items and, if found,
removes it from the array.

Array.contains(item)

Returns true if the items
exists in the array, false otherwise.

Array.find(func)

Evaluates the passed function for every item in the array and returns the first item that when passed as an argument to the function, makes the function return true.

If no items make the function evaluate to true, then null is
returned.

For example:

var item = someArray.find( function(item) { return item.a == 1; } );

Instead of:

var item;
for (var i=0; i < someArray.length; i++ )
{
  if( someArray[i].a == 1 )
   {
      item = someArray[i];
      break;
   }
}

Array.findIndex(func)

Evaluates the passed function for every item in the array and returns the first item that when passed as an argument to the function, makes the function return true.

If no items make the function evaluate to true, then -1 is returned.

Array.forEach(func)

Evaluates the passed function once for every item in the array passing two parameters each time. The first parameter is the item itself, and the second parameter is the array index where the item was retrieved from.

‹ PageupString Extensions ›
»
  • Printer-friendly version