Class Array

Index

Methods

Methods

public static clean(array?: Array<any>): Array<any>

[Method] Filter through an array and remove empty item as defined in Ext isEmpty

Parameters

  • array?: Array<any> optional

    Array

Returns

Array<any>

Array results

public static clone(array?: Array<any>): Array<any>

[Method] Clone a flat array without referencing the previous one

Parameters

  • array?: Array<any> optional

    Array The array

Returns

Array<any>

Array The clone array

public static contains(array?: Array<any>, item?: any): boolean

[Method] Checks whether or not the given array contains the specified item

Parameters

  • array?: Array<any> optional

    Array The array to check.

  • item?: any optional

    Object The item to look for.

Returns

boolean

Boolean true if the array contains the item, false otherwise.

public static difference(arrayA?: Array<any>, arrayB?: Array<any>): Array<any>

[Method] Perform a set difference A B by subtracting all items in array B from array A

Parameters

  • arrayA?: Array<any> optional

    Array

  • arrayB?: Array<any> optional

    Array

Returns

Array<any>

Array difference

public static each(iterable?: any, fn?: any, scope?: any, reverse?: boolean): boolean

[Method] Iterates an array or an iterable value and invoke the given callback function for each item

Parameters

  • iterable?: any optional

    Array/NodeList/Object The value to be iterated. If this argument is not iterable, the callback function is called once.

  • fn?: any optional

    Function The callback function. If it returns false, the iteration stops and this method returns the current index.

  • scope?: any optional

    Object The scope (this reference) in which the specified function is executed.

  • reverse?: boolean optional

    Boolean Reverse the iteration order (loop from the end to the beginning).

Returns

boolean

Boolean See description for the fn parameter.

public static erase(array?: Array<any>, index?: number, removeCount?: number): Array<any>

[Method] Removes items from an array

Parameters

  • array?: Array<any> optional

    Array The Array on which to replace.

  • index?: number optional

    Number The index in the array at which to operate.

  • removeCount?: number optional

    Number The number of items to remove at index.

Returns

Array<any>

Array The array passed.

public static every(array?: Array<any>, fn?: any, scope?: any): boolean

[Method] Executes the specified function for each array element until the function returns a falsy value

Parameters

  • array?: Array<any> optional

    Array

  • fn?: any optional

    Function Callback function for each item.

  • scope?: any optional

    Object Callback function scope.

Returns

boolean

Boolean true if no false value is returned by the callback function.

public static filter(array?: Array<any>, fn?: any, scope?: any): Array<any>

[Method] Creates a new array with all of the elements of this array for which the provided filtering function returns true

Parameters

  • array?: Array<any> optional

    Array

  • fn?: any optional

    Function Callback function for each item.

  • scope?: any optional

    Object Callback function scope.

Returns

Array<any>

Array results

public static flatten(array?: Array<any>): Array<any>

[Method] Recursively flattens into 1 d Array

Parameters

  • array?: Array<any> optional

    Array The array to flatten

Returns

Array<any>

Array The 1-d array.

public static forEach(array?: Array<any>, fn?: any, scope?: any)

[Method] Iterates an array and invoke the given callback function for each item

Parameters

  • array?: Array<any> optional

    Array The array to iterate.

  • fn?: any optional

    Function The callback function.

  • scope?: any optional

    Object The execution scope (this) in which the specified function is executed.

public static from(value?: any, newReference?: boolean): Array<any>

[Method] Converts a value to an array if it s not already an array returns An empty array if given value is undefined or n

Parameters

  • value?: any optional

    Object The value to convert to an array if it's not already is an array.

  • newReference?: boolean optional

    Boolean true to clone the given array and return a new reference if necessary.

Returns

Array<any>

Array array

public static include(array?: Array<any>, item?: any)

[Method] Push an item into the array only if the array doesn t contain it yet

Parameters

  • array?: Array<any> optional

    Array The array.

  • item?: any optional

    Object The item to include.

public static indexOf(array?: Array<any>, item?: any, from?: number): number

[Method] Get the index of the provided item in the given array a supplement for the missing arrayPrototype indexOf in Interne

Parameters

  • array?: Array<any> optional

    Array The array to check.

  • item?: any optional

    Object The item to look for.

  • from?: number optional

    Number The index at which to begin the search.

Returns

number

Number The index of item in the array (or -1 if it is not found).

public static insert(array?: Array<any>, index?: number, items?: Array<any>): Array<any>

[Method] Inserts items in to an array

Parameters

  • array?: Array<any> optional

    Array The Array on which to replace.

  • index?: number optional

    Number The index in the array at which to operate.

  • items?: Array<any> optional

    Array The array of items to insert at index.

Returns

Array<any>

Array The array passed.

public static intersect(array1?: Array<any>, array2?: Array<any>, etc?: Array<any>): Array<any>

[Method] Merge multiple arrays into one with unique items that exist in all of the arrays

Parameters

  • array1?: Array<any> optional

    Array

  • array2?: Array<any> optional

    Array

  • etc?: Array<any> optional

    Array

Returns

Array<any>

Array intersect

public static map(array?: Array<any>, fn?: any, scope?: any): Array<any>

[Method] Creates a new array with the results of calling a provided function on every element in this array

Parameters

  • array?: Array<any> optional

    Array

  • fn?: any optional

    Function Callback function for each item.

  • scope?: any optional

    Object Callback function scope.

Returns

Array<any>

Array results

public static max(array?: any, comparisonFn?: any): any

[Method] Returns the maximum value in the Array

Parameters

  • array?: any optional

    Array/NodeList The Array from which to select the maximum value.

  • comparisonFn?: any optional

    Function a function to perform the comparison which determines maximization. If omitted the ">" operator will be used. Note: gt = 1; eq = 0; lt = -1

Returns

any

Object maxValue The maximum value

public static mean(array?: Array<any>): number

[Method] Calculates the mean of all items in the array

Parameters

  • array?: Array<any> optional

    Array The Array to calculate the mean value of.

Returns

number

Number The mean.

public static merge(array1?: Array<any>, array2?: Array<any>, etc?: Array<any>): Array<any>

[Method] Merge multiple arrays into one with unique items

Parameters

  • array1?: Array<any> optional

    Array

  • array2?: Array<any> optional

    Array

  • etc?: Array<any> optional

    Array

Returns

Array<any>

Array merged

public static min(array?: any, comparisonFn?: any): any

[Method] Returns the minimum value in the Array

Parameters

  • array?: any optional

    Array/NodeList The Array from which to select the minimum value.

  • comparisonFn?: any optional

    Function a function to perform the comparison which determines minimization. If omitted the "<" operator will be used. Note: gt = 1; eq = 0; lt = -1

Returns

any

Object minValue The minimum value.

public static pluck(array?: any, propertyName?: string): Array<any>

[Method] Plucks the value of a property from each item in the Array

Parameters

  • array?: any optional

    Array/NodeList The Array of items to pluck the value from.

  • propertyName?: string optional

    String The property name to pluck from each element.

Returns

Array<any>

Array The value from each item in the Array.

public static remove(array?: Array<any>, item?: any): Array<any>

[Method] Removes the specified item from the array if it exists

Parameters

  • array?: Array<any> optional

    Array The array.

  • item?: any optional

    Object The item to remove.

Returns

Array<any>

Array The passed array itself.

public static replace(array?: Array<any>, index?: number, removeCount?: number, insert?: Array<any>): Array<any>

[Method] Replaces items in an array

Parameters

  • array?: Array<any> optional

    Array The Array on which to replace.

  • index?: number optional

    Number The index in the array at which to operate.

  • removeCount?: number optional

    Number The number of items to remove at index (can be 0).

  • insert?: Array<any> optional

    Array An array of items to insert at index.

Returns

Array<any>

Array The array passed.

public static slice(array?: Array<any>, begin?: number, end?: number): Array<any>

[Method] Returns a shallow copy of a part of an array

Parameters

  • array?: Array<any> optional

    Array The array (or arguments object).

  • begin?: number optional

    Number The index at which to begin. Negative values are offsets from the end of the array.

  • end?: number optional

    Number The index at which to end. The copied items do not include end. Negative values are offsets from the end of the array. If end is omitted, all items up to the end of the array are copied.

Returns

Array<any>

Array The copied piece of the array.

public static some(array?: Array<any>, fn?: any, scope?: any): boolean

[Method] Executes the specified function for each array element until the function returns a truthy value

Parameters

  • array?: Array<any> optional

    Array

  • fn?: any optional

    Function Callback function for each item.

  • scope?: any optional

    Object Callback function scope.

Returns

boolean

Boolean true if the callback function returns a truthy value.

public static sort(array?: Array<any>, sortFn?: any): Array<any>

[Method] Sorts the elements of an Array

Parameters

  • array?: Array<any> optional

    Array The array to sort.

  • sortFn?: any optional

    Function The comparison function.

Returns

Array<any>

Array The sorted array.

public static splice(array?: Array<any>, index?: number, removeCount?: number): Array<any>

[Method] Replaces items in an array

Parameters

  • array?: Array<any> optional

    Array The Array on which to replace.

  • index?: number optional

    Number The index in the array at which to operate.

  • removeCount?: number optional

    Number The number of items to remove at index (can be 0).

Returns

Array<any>

Array An array containing the removed items.

public static sum(array?: Array<any>): number

[Method] Calculates the sum of all items in the given array

Parameters

  • array?: Array<any> optional

    Array The Array to calculate the sum value of.

Returns

number

Number The sum.

public static toArray(iterable?: any, start?: number, end?: number): Array<any>

[Method] Converts any iterable numeric indices and a length property into a true array

Parameters

  • iterable?: any optional

    Object the iterable object to be turned into a true Array.

  • start?: number optional

    Number a zero-based index that specifies the start of extraction.

  • end?: number optional

    Number a zero-based index that specifies the end of extraction.

Returns

Array<any>

Array

public static union(array1?: Array<any>, array2?: Array<any>, etc?: Array<any>): Array<any>

[Method] Merge multiple arrays into one with unique items

Parameters

  • array1?: Array<any> optional

    Array

  • array2?: Array<any> optional

    Array

  • etc?: Array<any> optional

    Array

Returns

Array<any>

Array merged

public static unique(array?: Array<any>): Array<any>

[Method] Returns a new array with unique items

Parameters

  • array?: Array<any> optional

    Array

Returns

Array<any>

Array results