Friday, 15 March 2019

Sencha Extjs Array Utility classes

Folks,

Today we are going to discuss the basic and most important concept of Array utility methods.

Useful classes of Ext.Array

Ext.Array.erase(array, index, removeCount):


It will remove the item from an array

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

                // At index 0 erase 2 items.
     var a = Ext.Array.erase(['a', 'b', 'c', 'd', 'e'], 0, 2);  
     console.log(a); 
    // logs ["c", "d", "e"]
     

Ext.Array.unique(array)

Returns a new array with unique items.

               var a = [1, 2, 3, 4, 1, 2];
     var b = Ext.Array.unique(a);
     alert(b); // alerts [1, 2, 3, 4]


Ext.Array.merge(array1, array2, etc)

Merge multiple arrays into one with unique items.
union() is an alias for merge().

Ext.Array#union is an alias for Ext.Array#merge


               var a = [ 1, 2, 3 ];
     var b = [ 2, 3, 4 ];
     var c = [ 2, 3, 5 ];
     var d = [ 2, 3, 6 ];
     var e = Ext.Array.merge(a, b, c, d);
     alert(e); // alert [1, 2, 3, 4, 5, 6] - all items in a new array




 


No comments:

Post a Comment