Extjs4.0 Ext. array Functions

Source: Internet
Author: User
Ext. onready (function () {var array = ['1', '2', '3', '4', '1', '6', '7']; ext. array. clean (array); // ['1', '2', '3', '4', '6', '7']; Ext. array. clone (array); // clone the array Ext. array. contains (array, '1'); // returns true to check whether the array contains the specified Element var array2 = ['1', '2', '3', '4 ', '5', '6']; Ext. array. difference (array, array2); // return the elements ['', '7'] Ext. array. every (array, function (STR, index, array) {// traverses the second parameter of the array to execute the callback function (current element, current index, current array (array )) specify the scope to return false and return immediately // alert (STR); Return true ;}); Ext. array. filter (array, function (STR, index, array) {// traverses the second parameter of the array and executes the callback function (current element, current index, current array) to specify the return value of the scope: returns true to form a new array // alert (STR); Return true ;}); var array3 = ['1', '2', '3', '4 ', ['1', '2', '3'], '6', '7']; Ext. array. flatten (array3); // return value: tile the multi-dimensional array into a one-dimensional array Ext. array. foreach (array, function (STR, index, array) {// just traverse the array // alert (STR) ;}); Ext. array. from (array, true ); // convert the value to an array. If it is undefined or null, the returned null array itself is an array. Return the array iteratively. Return the array copy single value. Return the array ext containing this value. array. include (array, '20140901'); // insert 100 to the end of the array. The premise is that the array does not have a value of Ext. array. indexof (array, '20140901', 0); // search for the specified value in the array. The third parameter is the starting position. Return Value: Location alert (ext. array. intersect ([array, array2]); // merges multiple array elements with unique Ext. array. map (array, function (STR, index, array) {// returns STR ;}according to the returned value); Ext. array. max (array, function (S1, S2) {// return the maximum value in the array when the comparison function is used, the return value is negative, and the small value 0 is equal, and the positive value is return 0;}); Ext. array. mean ([1, 2, 3, 4, 5]); // returns the average value Ext. array. min (array, function (S1, S2) {// return the minimum value of the array. Return 0;}); var array4 = [{'a1 ': 'a1'}, {'a1': 'a2 '}, {'a3': 'a3'}]; Ext. array. pluck (array4, 'a1'); // search for the A1 value in the array JSON data and return the Array (without changing the array size) Ext. array. remove (array, '1'); // Delete the specified Element in the array. Note: Only one ext is deleted. array. some (array, function (S1, S2) {// returns true after traversing the array return false;}); var array5 = ['s ', 'A ', 'Z', 'C']; Ext. array. sort (array5); // by default, the sorting array is sorted by character. optional sorting function var array6 = [1, 2, 4, 5]; Ext. array. sum (array6); // sum Ext. array. toarray (array6, 2, 4); // convert any iteratable value to array parameter 1 iterable 2 start 3 endext. array. merge (array, array6); // composite array Ext. array. unique (array, array6); // composite array merge alias Ext. array. unique (array); // obtain a new array with unique elements })

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.