ES5 new method

First, the array method

 Iterative (traversing) Method: forEach (), map (), filter (), some (), every ();

 1. array. forEach(function(value,index,arr){})

  value: array value of the current item

  index: Array index of the current item

  arr: array object itself

 2. array.filter(function(value,index,arr){})

  filter () method creates a new array of new elements in the array is specified by examining all of the elements in the array qualified, mainly used for screening arrays

  Note: Direct returns a new array

 3.array.some(function(value,index,arr){})

  some () method for detecting elements in the array satisfies the specified conditions, popular point find whether there is the condition elements in the array.

  Note: The return value is a Boolean value, if find this element, it returns true, if you can not find the returns false.

  If the first element satisfies the condition is found, the loop is terminated, look no further.

4. forEach distinction and some of

 1. In return does not stop there forEach iteration

 2. encountered return true in some iteration of which is to terminate traversal higher efficiency.

 3. If only the lookup array element, using some suitable method is more (more efficient).

Second, the method of the string

Third, the object methods

Guess you like

Origin www.cnblogs.com/qtbb/p/11819255.html