extJs_Ext.Array_API

(Array array ) :Array

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

过滤掉数组中的项该项如果为空(Ext.isEmpty==true)则过滤掉

See filter

Parameters

Returns

例子:

    var arr = [1,4,2,12,,13];
    
    alert(arr.length); //{6个}
    var arr1 = Ext.Array.clean(arr);

    alert(arr1.length);//(5个)


   



( Array arrayA, Array arrayB ) : Array

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

对比两个数组A、B,返回A数组中的项在B数组中没有出现过的。

Parameters

Returns

例子:

Ext.onReady(function(){
    
//    Ext.MessageBox.alert("Hello","Hello Word!!");
    
    var arr1 = [1,4,2,12,13];
    var arr2 = [1,4,2,12,13,17];
    
    var resultArra = Ext.Array.difference(arr1,arr2);
    
    alert(resultArra.length);(返回0)

});


( Array/NodeList/Object iterable, Function fn, [Object scope], [Boolean reverse] ) : Boolean

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

遍历一个数组或是迭代一个值(这里迭代不准确,见例子),调用函数来循环每项的

var countries = ['Vietnam', 'Singapore', 'United States', 'Russia'];

Ext.Array.each(countries, function(name, index, countriesItSelf) {
    console.log(name);
});

var sum = function() {
    var sum = 0;

    Ext.Array.each(arguments, function(value) {
        sum += value;
    });

    return sum;
};

sum(1, 2, 3); // returns 6

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

在回调函数中通过return false来结束对conuntries的迭代

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

Ext.each is alias for Ext.Array.each

Parameters

  • iterable : Array/NodeList/Object

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

  • fn : Function

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

    Parameters

    • item : Object

      The item at the current index in the passed array

    • index : Number

      The current index within the array

    • allItems : Array

      The array itself which was passed as the first argument

    Returns

    • Boolean

      Return false to stop iteration.

  • scope : Object (optional)

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

  • reverse : Boolean (optional)

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

Returns

  • Boolean

    See description for the fn parameter.









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值