Ext JS Learning the Extended native JavaScript object of the day Ext Foundation (ii)

Source: Internet
Author: User
Tags string format

This article to record the study notes;

Continue today, Ext.array,ext.function,ext.date,ext.error.

--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------

Ext.array API to provide you with 33 methods, I am here to give you a list of parts, others crossing self-check API bar, are very simple

Ext.Array.clean (array array): Array filters out null values in the array
        var arr = [1,2,null,3,'];        Alert (Ext.Array.clean (arr)); // The result is a

Ext.Array.difference (Array Array1,array array2): Array

Returns the difference set of a-B, minus all elements present in a in a

        var arr1 = [1,2,3];         var arr2 = [2,5,6];        Alert (Ext.Array.difference (ARR1,ARR2)); // The result is 1,3

The Ext.Array.each (ARRAY,FN [scope]) enumeration array iterates through an array and processes each element of the array with the specified function Ext.Array.forEach (ARRAY,FN [scope])
        var arr = [1,2,3,4];        Ext.Array.each (arr,  function(item) {                if (item = = 4false  //  The iteration is stopped when false is returned inside the function
} alert (item);
});
 var  sum = function   () { var  sum = 0 function   (    Value) {sum  += value;    });  return   sum;}; SUM ( 1, 2, 3); //  return 6  

Ext.Array.erase ( array array, number index, number Removecount ): Array

Moves multiple elements in an array. This function is equivalent to the splice method of the array. However, IE8 's splice function bugs are avoided, and the removed elements are not copied and returned in order. (because they are usually ignored)

        var arr = [1,2,3,4,5];         2, 2)); // The result is 1,2,5

Ext.Array.every ( array array, Function FN, Object scope ): Boolean

        var arr = [1,2,5,6,9,10];         var function (item) {            if(item >=7) {                returnfalse  ;             } Else {                returntrue;                }        });        alert (flag); // false;

Ext.Array.filter ( array array, Function FN, Object scope ): Array

The method of filtering the array, for example, a chestnut;

        var arr = [1,2,3,4,10,18,23];         var newarr = Ext.Array.filter (arr,function(item) {            if(item >) {                 return false  ;              Else {                returntrue  ;            }        });        alert (newarr);//result is 1,2,3,4,10

Ext.Array.include (Array array,object Item)

Inserts an element into an array, if it does not exist in this array

        var arr = [1,2,3,4];         );        Alert (arr); // result 1,2,3,4,20

Ext.Array.unique (Array array

Returns a new array that removes duplicate elements

vararr = [1,2,3,4,5,5,4,3,2,1,1,21,23,3,3,4]; Alert (Ext.Array.unique (arr));
//Use the attributes of the JS object to remove duplicates of the array obj key cannot be duplicated varobj = {}; for(vari = 0, len = arr.length; I <len; i++) {Obj[arr[i]]=true;//Remove the duplicates of the array } //alert (Ext.encode (obj)); varUniquearr = []; for(varIinchobj) { if(Obj.hasownproperty (i)) {Uniquearr.push (i); }} alert (Uniquearr);

--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------

Ext.function API to provide you with 13 methods, are not used to say

--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------

Ext.date

Ext.Date.between (Date date,date start,date end): Boolean

Determines whether a given date is within a specified date

Alert (Ext.Date.between (new date (2014,08,15),new date (2014,08,01),new date (2014,08,31)) ); // result True

Ext.Date.format ( Date Date, string format ): string

Format a given time

Alert (Ext.Date.format (new Date (), ' y-m-d h:i:s '));

Ext.Date.parse ( string input, string format, [Boolean Strict] ): Date
Format time format

Alert (Ext.Date.parse (' 2010-07-05 21:22:22 ', ' y-m-d h:i:s '). toLocaleString ());

--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------

Ext.error just one way to get your attention.

Ext.Error.raise (' You are wrong ... ');

Ext extension Native JavaScript object is gone, see what's New Tomorrow

To recommend an article network www.fishcmonkey.com, learning to improve the literary accomplishment;

Ext JS Learning the Extended native JavaScript object of the day Ext Foundation (ii)

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.