ExtJS Learning-----------Ext.array,extjs extension to an Array in JavaScript (instance)

Source: Internet
Author: User

(1) Clean

var arr = [1,2,null,3, '];alert (Ext.Array.clean (arr));//clean object: (value = = null) | | (value = = undefined) | | (!allowemptystring? value = = = ': false) | | (Ext.isarray (value) && value.length = = = 0)//result for
(2) Difference

Differencevar arr1 = [1,2,3];var arr2 = [2,5,6];alert (Ext.Array.difference (ARR1,ARR2));//Result: 1,3
(3) each

Eachvar arr = [1,2,3,4]; Ext.Array.each (arr,  function (item) {if (item = = 4) {return false;} Alert (item),//////When the function returns False when the iteration is stopped});//Result: Popup dialog box, display 1 2 3 respectively, do not display 4
(4) Erase

Erasevar arr = [1,2,3,4,5];alert (Ext.Array.erase (arr, 2, 2));//array starting from 0. Start (include) from position subscript 2, delete two elements//result: three-in-one
(5) every

Everyvar arr = [1,2,5,6,9,10];var flag = Ext.Array.every (arr, function (item) {if (item >=7) {return false;} else {return true;}}); alert (flag);//Result: false
(6) Filter

Filtervar arr = [1,2,3,4,10,18,23];var newarr = Ext.Array.filter (arr,function (item) {if (item >) {return false;} El SE {return true;}}); alert (newarr);//Result: 1,2,3,4,10
(7) Include

Includevar arr = [1,2,3,4]; Ext.Array.include (arr, 2); alert (arr);//Result: 1,2,3,4
(8) Unique

Unqiuevar arr = [1,2,3,4,5,5,4,3,2,1,1,21,23,3,3,4];alert (Ext.Array.unique (arr));//Use the JS object's attributes to remove duplicates  of the array The key of obj is not repeatable var obj = {};for (var i = 0, len = arr.length; i <len; i++) {Obj[arr[i]] = true;//Remove duplicates of the array}//alert (EXT . Encode (obj)), var uniquearr = [];for (var i in obj) {if (Obj.hasownproperty (i)) {Uniquearr.push (i);}} alert (Uniquearr);//Result: 1,2,3,4,5,21,23











ExtJS Learning-----------Ext.array,extjs extension to an Array in JavaScript (instance)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.