Methods array of objects

1 bake ()  

  a) connecting two or more arrays, and returns the result

  b) for performing the method returns a new array, the array has no effect on the original

  c) a plurality of parameters may be, a plurality of which are not filled can be filled

 

 

 2、every()

  Whether each element a) are in line with the conditions of the detection array

  b) Return Value: If there is an array of non-compliance with returns false, all in compliance with returns true

  c) Parameters Parameter both a first parameter is a callback function (a function parameter)

    The callback must return a value, the result returned is a boolean, otherwise not

    Callback function parameter is the current element and the current element corresponding index

    The second function is an object, optional replacement for the callback function in this

3、filter()

  a) detecting elements in the array, it returns the right elements constituting the new array

  b) Return Value: returns a new array

  c) The first parameter is a parameter callback

    The first parameter is the callback of the current element, the callback must return a result

    The second parameter is the callback element corresponding to the current index

    The second function is to replace this callback

 

4、find()

  a) each element in the array are called once, returns the first matching element

  b) the value returned is the first matching element

  c) Parameters

    The first parameter is the callback must return a value

    The second parameter in this alternative directed callback

 

 

 5、findindex

  Each element in the array once, returns the index of the first qualifying of the array elements

  Usage and find () as

6, foeEach ()

  Each element of the array call, and elements are passed to the callback with the for loop as

    Is a process of elements, no return value

  The return value is not always return undefined

  The first parameter is the callback parameter

     The second parameter is used in this alternative directed callback

 

 

 7、map()

  Returns a new array, the new array element is performed after the return value of the callback

  Return Value: returns a new array

  Parameters The first parameter is the callback callback must return a value

      The second parameter in this alternative callback

 

8、includes()

 

  Analyzing an array contains a specified value has no returns true returns false

  Return value boolean

  Values ​​of the parameters specified

 

9、indexof()

  Searching for an element position in the array, the index has returned to his, not to return -1

  Returns the index values ​​of the digital and -1

  Values ​​of the parameters specified

 

 Deduplication Array

 

 10、join()

  All elements in the array will be converted into a string

  Returns Returns new string

  Parameter specifies the dividing line does not write default is a comma

 

 11、push()

  Modify the original array to add new elements to the end of the array of items

  The return value is the length of the new array

  Parameter elements

 

 12、pop()

  The last element of the original array is modified to delete the array

  The value returned is to remove that element

  Parameters no parameters

 

 13、Reduce()

  Current element operation callback function, a return value can not be separated before the element. From the beginning of the second term is generally performed

  return value

  Parameters The first parameter is a callback function must return a value are undefined otherwise

    The first parameter a) is the callback total

      total is the preceding element corresponding to the return value of the callback function

    b) The second parameter is the current element callback

    The third parameter c) the callback function is the index value of the current corresponding to the elements

 

   The second argument is an initial value, if written, reduce the first term started from this initial value as the first term pullback in the total, if you do not write, execute from the beginning of the second term, the first element is the first two in the total

14 , Reverse () inverted array

Reverse the order of the array

The return value is an array of the reversed, changed the original array

Parameters no parameters

 

15 unshift()

Add one or more elements to the beginning of an array

The return value  of new added length of the array upon return

参数  要添加的元素

 

16 shift()

删除数组中的第一个元素

返回值  返回被删除的那个元素

参数  没有参数

 

17slice()

从原数组中截取并返回一部分元素

返回值 一个新数组 截取到的元素构成的新数组

参数 开始的位置 和结束的位置 不包含最后一个元素)前闭后开

 

18.some()

检索数组中是否有符合条件的元素,只要有一个符合 返回true,全不符合返回false

返回值就是boolean

参数 是一个回调函数 回调函数里必须有返回值

 

19sort()

对数组的元素进行排序 0-9-a-z顺序排列

返回值 排列后的新数组

参数 callback

 

Callback 规定sort的排列方式

 

20.splice()

从数组中指定的某一项开始删除元素或添加新元素 会改变原有的数组

返回值 是一个数组 如果删除了元素 返回的是这写删除元素构成的新数组

  如果没有删除 返回的是一个空数组

参数 第一参数 必须填 起始位置

 第二个参数  删除元素的个数 可以是代表没有删除 不填删除后面所有的

 第三类参数  从第三个参数开始 后面都是添加的新元素

 

21.toString()

将数组转化为字符串 并返回这个字符串

返回值  转化后的字符串

参数 没有参数

 

Guess you like

Origin www.cnblogs.com/d1011/p/12404164.html