Ext.data.JsonP.Ext_Array({"alternateClassNames":[],"aliases":{},"enum":null,"parentMixins":[],"tagname":"class","subclasses":[],"extends":null,"uses":[],"html":"

Files

A set of useful static methods to deal with arrays; provide missing methods for older browsers.

\n
Defined By

Methods

Ext.Array
view source
( array ) : Array
Filter through an array and remove empty item as defined in Ext.isEmpty\n\nSee filter ...

Filter through an array and remove empty item as defined in Ext.isEmpty

\n\n

See filter

\n

Parameters

Returns

Ext.Array
view source
( array ) : Array
Clone a flat array without referencing the previous one. ...

Clone a flat array without referencing the previous one. Note that this is different\nfrom Ext.clone since it doesn't handle recursive cloning. It's simply a convenient, easy-to-remember method\nfor Array.prototype.slice.call(array)

\n

Parameters

Returns

Ext.Array
view source
( array, item ) : Boolean
Checks whether or not the given array contains the specified item ...

Checks whether or not the given array contains the specified item

\n

Parameters

  • array : Array

    The array to check

    \n
  • item : Object

    The item to look for

    \n

Returns

  • Boolean

    True if the array contains the item, false otherwise

    \n
Ext.Array
view source
( arrayA, arrayB ) : Array
Perform a set difference A-B by subtracting all items in array B from array A. ...

Perform a set difference A-B by subtracting all items in array B from array A.

\n

Parameters

Returns

Ext.Array
view source
( iterable, fn, [scope], [reverse] ) : Boolean
Iterates an array or an iterable value and invoke the given callback function for each item. ...

Iterates an array or an iterable value and invoke the given callback function for each item.

\n\n
var countries = ['Vietnam', 'Singapore', 'United States', 'Russia'];\n\nExt.Array.each(countries, function(name, index, countriesItSelf) {\n    console.log(name);\n});\n\nvar sum = function() {\n    var sum = 0;\n\n    Ext.Array.each(arguments, function(value) {\n        sum += value;\n    });\n\n    return sum;\n};\n\nsum(1, 2, 3); // returns 6\n
\n\n

The iteration can be stopped by returning false in the function callback.

\n\n
Ext.Array.each(countries, function(name, index, countriesItSelf) {\n    if (name === 'Singapore') {\n        return false; // break here\n    }\n});\n
\n\n

Ext.each is alias for Ext.Array.each

\n

Parameters

  • iterable : Array/NodeList/Object

    The value to be iterated. If this\nargument is not iterable, the callback function is called once.

    \n
  • fn : Function

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

    \n

    Parameters

    • item : Object

      The item at the current index in the passed array

      \n
    • index : Number

      The current index within the array

      \n
    • allItems : Array

      The array itself which was passed as the first argument

      \n

    Returns

    • Boolean

      Return false to stop iteration.

      \n
  • scope : Object (optional)

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

    \n
  • reverse : Boolean (optional)

    Reverse the iteration order (loop from the end to the beginning)\nDefaults false

    \n

Returns

  • Boolean

    See description for the fn parameter.

    \n
Ext.Array
view source
( array1, array2 ) : Boolean
Shallow compares the contents of 2 arrays using strict equality. ...

Shallow compares the contents of 2 arrays using strict equality.

\n

Parameters

Returns

  • Boolean

    true if the arrays are equal.

    \n
Ext.Array
view source
( array, index, removeCount ) : Array
Removes items from an array. ...

Removes items from an array. This is functionally equivalent to the splice method\nof Array, but works around bugs in IE8's splice method and does not copy the\nremoved elements in order to return them (because very often they are ignored).

\n

Parameters

  • array : Array

    The Array on which to replace.

    \n
  • index : Number

    The index in the array at which to operate.

    \n
  • removeCount : Number

    The number of items to remove at index.

    \n

Returns

Ext.Array
view source
( array, fn, scope ) : Boolean
Executes the specified function for each array element until the function returns a falsy value. ...

Executes the specified function for each array element until the function returns a falsy value.\nIf such an item is found, the function will return false immediately.\nOtherwise, it will return true.

\n

Parameters

  • array : Array
    \n
  • fn : Function

    Callback function for each item

    \n

    Parameters

    • item : Mixed

      Current item.

      \n
    • index : Number

      Index of the item.

      \n
    • array : Array

      The whole array that's being iterated.

      \n
  • scope : Object

    Callback function scope

    \n

Returns

  • Boolean

    True if no false value is returned by the callback function.

    \n
Ext.Array
view source
( array, fn, scope ) : Array
Creates a new array with all of the elements of this array for which\nthe provided filtering function returns true. ...

Creates a new array with all of the elements of this array for which\nthe provided filtering function returns true.

\n

Parameters

  • array : Array
    \n
  • fn : Function

    Callback function for each item

    \n

    Parameters

    • item : Mixed

      Current item.

      \n
    • index : Number

      Index of the item.

      \n
    • array : Array

      The whole array that's being iterated.

      \n
  • scope : Object

    Callback function scope

    \n

Returns

Ext.Array
view source
( array, fn, [scope] ) : Object
Returns the first item in the array which elicits a true return value from the\npassed selection function. ...

Returns the first item in the array which elicits a true return value from the\npassed selection function.

\n

Parameters

  • array : Array

    The array to search

    \n
  • fn : Function

    The selection function to execute for each item.

    \n

    Parameters

    • item : Mixed

      The array item.

      \n
    • index : String

      The index of the array item.

      \n
  • scope : Object (optional)

    The scope (this reference) in which the\nfunction is executed. Defaults to the array

    \n

Returns

  • Object

    The first item in the array which returned true from the selection\nfunction, or null if none was found.

    \n
Ext.Array
view source
( array ) : Array
Recursively flattens into 1-d Array. ...

Recursively flattens into 1-d Array. Injects Arrays inline.

\n

Parameters

  • array : Array

    The array to flatten

    \n

Returns

Ext.Array
view source
( array, fn, [scope] )
Iterates an array and invoke the given callback function for each item. ...

Iterates an array and invoke the given callback function for each item. Note that this will simply\ndelegate to the native Array.prototype.forEach method if supported. It doesn't support stopping the\niteration by returning false in the callback function like each. However, performance\ncould be much better in modern browsers comparing with each

\n

Parameters

  • array : Array

    The array to iterate

    \n
  • fn : Function

    The callback function.

    \n

    Parameters

    • item : Object

      The item at the current index in the passed array

      \n
    • index : Number

      The current index within the array

      \n
    • allItems : Array

      The array itself which was passed as the first argument

      \n
  • scope : Object (optional)

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

    \n
Ext.Array
view source
( value, [newReference] ) : Array
Converts a value to an array if it's not already an array; returns:\n\n\nAn empty array if given value is undefined or n...

Converts a value to an array if it's not already an array; returns:

\n\n
    \n
  • An empty array if given value is undefined or null
  • \n
  • Itself if given value is already an array
  • \n
  • An array copy if given value is iterable (arguments, NodeList and alike)
  • \n
  • An array with one item which is the given value, otherwise
  • \n
\n\n

Parameters

  • value : Object

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

    \n
  • newReference : Boolean (optional)

    True to clone the given array and return a new reference if necessary,\ndefaults to false

    \n

Returns

Ext.Array
view source
( array, item )
Push an item into the array only if the array doesn't contain it yet ...

Push an item into the array only if the array doesn't contain it yet

\n

Parameters

  • array : Array

    The array

    \n
  • item : Object

    The item to include

    \n
Ext.Array
view source
( array, item, [from] ) : Number
Get the index of the provided item in the given array, a supplement for the\nmissing arrayPrototype.indexOf in Interne...

Get the index of the provided item in the given array, a supplement for the\nmissing arrayPrototype.indexOf in Internet Explorer.

\n

Parameters

  • array : Array

    The array to check

    \n
  • item : Object

    The item to look for

    \n
  • from : Number (optional)

    The index at which to begin the search

    \n

Returns

  • Number

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

    \n
Ext.Array
view source
( array, index, items ) : Array
Inserts items in to an array. ...

Inserts items in to an array.

\n

Parameters

  • array : Array

    The Array in which to insert.

    \n
  • index : Number

    The index in the array at which to operate.

    \n
  • items : Array

    The array of items to insert at index.

    \n

Returns

Ext.Array
view source
( array1, array2, etc ) : Array
Merge multiple arrays into one with unique items that exist in all of the arrays. ...

Merge multiple arrays into one with unique items that exist in all of the arrays.

\n

Parameters

Returns

Ext.Array
view source
( array, fn, [scope] ) : Array
Creates a new array with the results of calling a provided function on every element in this array. ...

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

\n

Parameters

  • array : Array
    \n
  • fn : Function

    Callback function for each item

    \n

    Parameters

    • item : Mixed

      Current item.

      \n
    • index : Number

      Index of the item.

      \n
    • array : Array

      The whole array that's being iterated.

      \n
  • scope : Object (optional)

    Callback function scope

    \n

Returns

Ext.Array
view source
( array, [comparisonFn] ) : Object
Returns the maximum value in the Array. ...

Returns the maximum value in the Array.

\n

Parameters

  • array : Array/NodeList

    The Array from which to select the maximum value.

    \n
  • comparisonFn : Function (optional)

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

    \n

    Parameters

    • max : Mixed

      Current maximum value.

      \n
    • item : Mixed

      The value to compare with the current maximum.

      \n

Returns

  • Object

    maxValue The maximum value

    \n
Ext.Array
view source
( array ) : Number
Calculates the mean of all items in the array. ...

Calculates the mean of all items in the array.

\n

Parameters

  • array : Array

    The Array to calculate the mean value of.

    \n

Returns

Ext.Array
view source
( array1, array2, etc ) : Array
Merge multiple arrays into one with unique items. ...

Merge multiple arrays into one with unique items.

\n\n

union is alias for merge

\n

Parameters

Returns

Ext.Array
view source
( array, [comparisonFn] ) : Object
Returns the minimum value in the Array. ...

Returns the minimum value in the Array.

\n

Parameters

  • array : Array/NodeList

    The Array from which to select the minimum value.

    \n
  • comparisonFn : Function (optional)

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

    \n

    Parameters

    • min : Mixed

      Current minimum value.

      \n
    • item : Mixed

      The value to compare with the current minimum.

      \n

Returns

  • Object

    minValue The minimum value

    \n
Ext.Array
view source
( array, propertyName ) : Array
Plucks the value of a property from each item in the Array. ...

Plucks the value of a property from each item in the Array. Example:

\n\n
Ext.Array.pluck(Ext.query(\"p\"), \"className\"); // [el1.className, el2.className, ..., elN.className]\n
\n

Parameters

  • array : Array/NodeList

    The Array of items to pluck the value from.

    \n
  • propertyName : String

    The property name to pluck from each element.

    \n

Returns

  • Array

    The value from each item in the Array.

    \n
Ext.Array
view source
( target, elements ) : Array
Pushes new items onto the end of an Array. ...

Pushes new items onto the end of an Array.

\n\n

Passed parameters may be single items, or arrays of items. If an Array is found in the argument list, all its\nelements are pushed into the end of the target Array.

\n

Parameters

  • target : Array

    The Array onto which to push new items

    \n
  • elements : Object...

    The elements to add to the array. Each parameter may\nbe an Array, in which case all the elements of that Array will be pushed into the end of the\ndestination Array.

    \n

Returns

  • Array

    An array containing all the new items push onto the end.

    \n
Ext.Array
view source
( array, item ) : Array
Removes the specified item from the array if it exists ...

Removes the specified item from the array if it exists

\n

Parameters

  • array : Array

    The array

    \n
  • item : Object

    The item to remove

    \n

Returns

  • Array

    The passed array itself

    \n
Ext.Array
view source
( array, index, removeCount, [insert] ) : Array
Replaces items in an array. ...

Replaces items in an array. This is functionally equivalent to the splice method\nof Array, but works around bugs in IE8's splice method and is often more convenient\nto call because it accepts an array of items to insert rather than use a variadic\nargument list.

\n

Parameters

  • array : Array

    The Array on which to replace.

    \n
  • index : Number

    The index in the array at which to operate.

    \n
  • removeCount : Number

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

    \n
  • insert : Array (optional)

    An array of items to insert at index.

    \n

Returns

Ext.Array
view source
( array, begin, end ) : Array
Returns a shallow copy of a part of an array. ...

Returns a shallow copy of a part of an array. This is equivalent to the native\ncall \"Array.prototype.slice.call(array, begin, end)\". This is often used when \"array\"\nis \"arguments\" since the arguments object does not supply a slice method but can\nbe the context object to Array.prototype.slice.

\n

Parameters

  • array : Array

    The array (or arguments object).

    \n
  • begin : Number

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

    \n
  • end : Number

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

    \n

Returns

  • Array

    The copied piece of the array.

    \n
Ext.Array
view source
( array, fn, scope ) : Boolean
Executes the specified function for each array element until the function returns a truthy value. ...

Executes the specified function for each array element until the function returns a truthy value.\nIf such an item is found, the function will return true immediately. Otherwise, it will return false.

\n

Parameters

  • array : Array
    \n
  • fn : Function

    Callback function for each item

    \n

    Parameters

    • item : Mixed

      Current item.

      \n
    • index : Number

      Index of the item.

      \n
    • array : Array

      The whole array that's being iterated.

      \n
  • scope : Object

    Callback function scope

    \n

Returns

  • Boolean

    True if the callback function returns a truthy value.

    \n
Ext.Array
view source
( array, [sortFn] ) : Array
Sorts the elements of an Array. ...

Sorts the elements of an Array.\nBy default, this method sorts the elements alphabetically and ascending.

\n

Parameters

  • array : Array

    The array to sort.

    \n
  • sortFn : Function (optional)

    The comparison function.

    \n

    Parameters

    • a : Mixed

      An item to compare.

      \n
    • b : Mixed

      Another item to compare.

      \n

Returns

Ext.Array
view source
( array, index, removeCount, elements ) : Array
Replaces items in an array. ...

Replaces items in an array. This is equivalent to the splice method of Array, but\nworks around bugs in IE8's splice method. The signature is exactly the same as the\nsplice method except that the array is the first argument. All arguments following\nremoveCount are inserted in the array at index.

\n

Parameters

  • array : Array

    The Array on which to replace.

    \n
  • index : Number

    The index in the array at which to operate.

    \n
  • removeCount : Number

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

    \n
  • elements : Object...

    The elements to add to the array. If you don't specify\nany elements, splice simply removes elements from the array.

    \n

Returns

  • Array

    An array containing the removed items.

    \n
Ext.Array
view source
( array ) : Number
Calculates the sum of all items in the given array. ...

Calculates the sum of all items in the given array.

\n

Parameters

  • array : Array

    The Array to calculate the sum value of.

    \n

Returns

Ext.Array
view source
( iterable, [start], [end] ) : Array
Converts any iterable (numeric indices and a length property) into a true array. ...

Converts any iterable (numeric indices and a length property) into a true array.

\n\n
function test() {\n    var args = Ext.Array.toArray(arguments),\n        fromSecondToLastArgs = Ext.Array.toArray(arguments, 1);\n\n    alert(args.join(' '));\n    alert(fromSecondToLastArgs.join(' '));\n}\n\ntest('just', 'testing', 'here'); // alerts 'just testing here';\n                                 // alerts 'testing here';\n\nExt.Array.toArray(document.getElementsByTagName('div')); // will convert the NodeList into an array\nExt.Array.toArray('splitted'); // returns ['s', 'p', 'l', 'i', 't', 't', 'e', 'd']\nExt.Array.toArray('splitted', 0, 3); // returns ['s', 'p', 'l']\n
\n\n

Ext.toArray is alias for Ext.Array.toArray

\n

Parameters

  • iterable : Object

    the iterable object to be turned into a true Array.

    \n
  • start : Number (optional)

    a zero-based index that specifies the start of extraction. Defaults to 0

    \n
  • end : Number (optional)

    a 1-based index that specifies the end of extraction. Defaults to the last\nindex of the iterable value

    \n

Returns

Ext.Array
view source
( array, [getKey], [scope] ) : Object
Creates a map (object) keyed by the elements of the given array. ...

Creates a map (object) keyed by the elements of the given array. The values in\nthe map are the index+1 of the array element. For example:

\n\n
 var map = Ext.Array.toMap(['a','b','c']);\n\n // map = { a: 1, b: 2, c: 3 };\n
\n\n

Or a key property can be specified:

\n\n
 var map = Ext.Array.toMap([\n         { name: 'a' },\n         { name: 'b' },\n         { name: 'c' }\n     ], 'name');\n\n // map = { a: 1, b: 2, c: 3 };\n
\n\n

Lastly, a key extractor can be provided:

\n\n
 var map = Ext.Array.toMap([\n         { name: 'a' },\n         { name: 'b' },\n         { name: 'c' }\n     ], function (obj) { return obj.name.toUpperCase(); });\n\n // map = { A: 1, B: 2, C: 3 };\n
\n

Parameters

  • array : Array

    The Array to create the map from.

    \n
  • getKey : String/Function (optional)

    Name of the object property to use\nas a key or a function to extract the key.

    \n
  • scope : Object (optional)

    Value of this inside callback.

    \n

Returns

Ext.Array
view source
( array, [getKey], [scope] ) : Object
Creates a map (object) keyed by a property of elements of the given array. ...

Creates a map (object) keyed by a property of elements of the given array. The values in\nthe map are the array element. For example:

\n\n
 var map = Ext.Array.toMap(['a','b','c']);\n\n // map = { a: 'a', b: 'b', c: 'c' };\n
\n\n

Or a key property can be specified:

\n\n
 var map = Ext.Array.toMap([\n         { name: 'a' },\n         { name: 'b' },\n         { name: 'c' }\n     ], 'name');\n\n // map = { a: {name: 'a'}, b: {name: 'b'}, c: {name: 'c'} };\n
\n\n

Lastly, a key extractor can be provided:

\n\n
 var map = Ext.Array.toMap([\n         { name: 'a' },\n         { name: 'b' },\n         { name: 'c' }\n     ], function (obj) { return obj.name.toUpperCase(); });\n\n // map = { A: {name: 'a'}, B: {name: 'b'}, C: {name: 'c'} };\n
\n

Parameters

  • array : Array

    The Array to create the map from.

    \n
  • getKey : String/Function (optional)

    Name of the object property to use\nas a key or a function to extract the key.

    \n
  • scope : Object (optional)

    Value of this inside callback.

    \n

Returns

Ext.Array
view source
( array1, array2, etc ) : Array
Merge multiple arrays into one with unique items. ...

Merge multiple arrays into one with unique items.

\n\n

union is alias for merge

\n

Parameters

Returns

Ext.Array
view source
( array ) : Array
Returns a new array with unique items ...

Returns a new array with unique items

\n

Parameters

Returns

","superclasses":[],"meta":{"author":["Jacky Nguyen "],"docauthor":["Jacky Nguyen "]},"requires":[],"html_meta":{"author":null,"docauthor":null},"statics":{"property":[],"cfg":[],"css_var":[],"method":[],"event":[],"css_mixin":[]},"files":[{"href":"Array2.html#Ext-Array","filename":"Array.js"}],"linenr":5,"members":{"property":[],"cfg":[],"css_var":[],"method":[{"tagname":"method","owner":"Ext.Array","meta":{},"name":"clean","id":"method-clean"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"clone","id":"method-clone"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"contains","id":"method-contains"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"difference","id":"method-difference"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"each","id":"method-each"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"equals","id":"method-equals"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"erase","id":"method-erase"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"every","id":"method-every"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"filter","id":"method-filter"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"findBy","id":"method-findBy"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"flatten","id":"method-flatten"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"forEach","id":"method-forEach"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"from","id":"method-from"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"include","id":"method-include"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"indexOf","id":"method-indexOf"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"insert","id":"method-insert"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"intersect","id":"method-intersect"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"map","id":"method-map"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"max","id":"method-max"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"mean","id":"method-mean"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"merge","id":"method-merge"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"min","id":"method-min"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"pluck","id":"method-pluck"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"push","id":"method-push"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"remove","id":"method-remove"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"replace","id":"method-replace"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"slice","id":"method-slice"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"some","id":"method-some"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"sort","id":"method-sort"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"splice","id":"method-splice"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"sum","id":"method-sum"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"toArray","id":"method-toArray"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"toMap","id":"method-toMap"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"toValueMap","id":"method-toValueMap"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"union","id":"method-union"},{"tagname":"method","owner":"Ext.Array","meta":{},"name":"unique","id":"method-unique"}],"event":[],"css_mixin":[]},"inheritable":null,"private":null,"component":false,"name":"Ext.Array","singleton":true,"override":null,"inheritdoc":null,"id":"class-Ext.Array","mixins":[],"mixedInto":[]});