Yahoo! UI Library

yui  3.0.0pr2

Yahoo! UI Library > yui > YUI~array
Search:
 
Filters

Class YUI~array

Adds the following array utilities to the YUI instance

Methods

Array

static Array Array ( o , i , al )
Y.Array(o) returns an array: - Arrays are return unmodified unless the start position is specified. - "Array-like" collections (@see Array.test) are converted to arrays - For everything else, a new array is created with the input as the sole item - The start position is used if the input is or is like an array to return a subset of the collection.
Parameters:
o <object> the item to arrayify
i <int> if an array or array-like, this is the start index
al <boolean> if true, it forces the array-like fork. This can be used to avoid multiple array.test calls.
Returns: Array
the resulting array

Array.each

static YUI Array.each ( a , f , o )
Executes the supplied function on each item in the array.
Parameters:
a <Array> the array to iterate
f <Function> the function to execute on each item
o <object> Optional context object
Returns: YUI
the YUI instance

Array.hash

static object Array.hash ( k , v )
Returns an object using the first array as keys, and the second as values. If the second array is not provided the value is set to true for each.
Parameters:
k <Array> keyset
v <Array> optional valueset
Returns: object
the hash

Array.indexOf

static int Array.indexOf ( a , val )
Returns the index of the first item in the array that contains the specified value, -1 if the value isn't found.
Parameters:
a <Array> the array to search
val <object> the value to search for
Returns: int
the index of the item that contains the value or -1

Array.some

static boolean Array.some ( a , f , o )
Executes the supplied function on each item in the array. Returning true from the processing function will stop the processing of the remaining items.
Parameters:
a <Array> the array to iterate
f <Function> the function to execute on each item
o <object> Optional context object
Returns: boolean
true if the

Array.test

static int Array.test ( )
Evaluates the input to determine if it is an array, array-like, or something else. This is used to handle the arguments collection available within functions, and HTMLElement collections
Returns: int
a number indicating the results: 0: Not an array or an array-like collection 1: A real array. 2: array-like collection.


Copyright © 2008 Yahoo! Inc. All rights reserved.