trunk/research/players/js/winlin.utility.js
/**
 * get the specified element from array
 * @param arr the array to find.
 * @param elem_or_function the element value or compare function.
 * @returns the matched elem; otherwise null.
 * for example,
 *      arr = [10, 15, 20, 30, 20, 40]
 *      system_array_get(arr, 10) // 10
 *      system_array_get(arr, 11) // null
 *      system_array_get(arr, function(elem){return elem == 30;}); // 30
 *      system_array_get(arr, function(elem){return elem == 60;}); // null
 */
get the specified element from array
@param arr the array to find.
@param elem_or_function the element value or compare function.
@returns the matched elem; otherwise null.
get the specified element from array @param arr the array to find . @param elem_or_function the element value or compare function . @returns the matched elem ; otherwise null .
function system_array_get(arr, elem_or_function) {
    for (var i = 0; i < arr.length; i++) {
        if (typeof elem_or_function == "function") {
            if (elem_or_function(arr[i])) {
                return arr[i];
            }
        } else {
            if (elem_or_function == arr[i]) {
                return arr[i];
            }
        }
    }
    return null;
}
function system_array_get ( arr , elem_or_function ) { for ( var i = 0 ; i < arr . length ; i ++ ) { if ( typeof elem_or_function == "function" ) { if ( elem_or_function ( arr [ i ] ) ) { return arr [ i ] ; } } else { if ( elem_or_function == arr [ i ] ) { return arr [ i ] ; } } } return null ; }
get the specified element from array
 @param arr the array to find.
get the specified element from array @param arr the array to find .