ES6 array Api expansion

1, Array.of (); ---- converting a set of data into an array;

201314 NUM = const ; 
   const A = Array.of (NUM); 
     the console.log (A);   // array of a length;

2. includes (); ----- detecting a particular array there, returns a Boolean value, if returns true, false if not;

ARR = the let [2,3,45,6,9 ]; 
    the let A = arr.includes (. 9 ); 
     the console.log (A)    // detector array there is no particular one! ! It returns a Boolean value; true / false;

3. fill (parameter 1, parameter 2, parameter 3) replacement of array elements;

ARR = the let [1,4,7,2,5,8,3 ] 
    the let of arr1 = arr.fill (88,2,4 ); 
     the console.log (of arr1)   // replace array elements; 
    first parameter added to the number; 
    the second parameter is the index of the start, 
    the third parameter is the end of the index,

 

 4. find ((value, index, arr) => {}) According to a recent condition returns to enjoy life and the condition value; parameter is a callback function, if not, return -1;

ARR = the let [1,2,3,5,8,6 ] 
    the let arr2 is = arr.find ((value, index, ARR) => {
        // return index>. 3; ----. 8, greater than the current index a recent value; 
        // a recent --- 5, is greater than the current value;; return value>. 3 
     })
     // // return to the condition according to the condition matching a latest value; 
    // the console.log (arr2)

5.findIndex (() => {}); return satisfies the test condition first array index entry; if not, it returns -1

ARR = the let [2,1,5,6,9,7 ]; 
    the let of arr1 = arr.findIndex ((value) => {
          return value>. 5; ----. 3 
     })   // Returns satisfies the test condition an index entry array 
     console.log (arr1)

6. Array.from () transferred the dummy array into an array;

Array.from () 
                dummy array into an array 
         var DOM document.getElementsByTagName = ( '*' );
          var ARR = Array.from (DOM); 
         the console.log (ARR);

                                

 

Guess you like

Origin www.cnblogs.com/gzw-23/p/11748643.html