JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

Array.concat()

Array.concat()


concatenate arrays

Synopsis

array.concat(value, ...)

Arguments

value, ... Any number of values to be concatenated with array.

Returns

A new array, which is formed by concatenating each of the specified arguments to array.

Description

concat() creates and returns a new array that is the result of concatenating each of its arguments to array. It does not modify array. If any of the arguments to concat()is itself an array, the elements of that array are concatenated, rather than the array itself.

Example

var a = [1,2,3]; a.concat(4, 5) // Returns [1,2,3,4,5] a.concat([4,5]); // Returns [1,2,3,4,5] a.concat([4,5],[6,7]) // Returns [1,2,3,4,5,6,7] a.concat(4, [5,[6,7]]) // Returns [1,2,3,4,5,[6,7]]

See Also

Array.join() , Array.push() , Array.splice()

Array.every() ECMAScript 5

test whether a predicate is true for every element Array.filter()

Synopsis

array.every(predicate) array.every(predicate, o)

Arguments

predicate

A predicate function to test array elements

o The optional this value for invocations of predicate.

Returns

true if predicate returns true (or any truthy value) for every element of array or false if the predicate returns false (or a falsy value) for any element.

Description

The every() method tests whether some condition holds for all elements of an array. It loops through the elements of array, in ascending order, and invokes the specified predicate function on each element in turn. If predicate returns false (or any value that converts to false), then every() stops looping and returns false immediately. If every invocation of predicate returns true, then every() returns true. When invoked on an empty array, every() returns true.

For each array index i, predicate is invoked with three arguments: predicate(array[i], i, array)

The return value of predicate is interpreted as a boolean value. true and all truthy values indicate that the array element passes the test or meets the condition described by that function. A return value of falseor any falsy value means that the array element does not pass the test.

See Array.forEach() for further details.

Example

[1,2,3].every(function(x) { return x < 5; }) // => true: all elts are < 5 [1,2,3].every(function(x) { return x < 3; }) // => false: all elts are not < 3 [].every(function(x) { return false; }); // => true: always true for []

See Also

Array.filter() , Array.forEach() , Array.some()

欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/28216.html
友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1