In es6, the function of some is to detect whether there is an element with specified conditions in the array; if the specified element exists, the returned result is true, if the specified element does not exist, the returned result is false, syntax is "array.some(callback function),thisValue)".
The operating environment of this article: Windows 10 system, ECMAScript version 6.0, DELL G3 computer.
The some() method tests whether an element in the array passes the test implemented by the provided function.
Syntax
array.some(callback[, thisObject]);
Parameter details
callback - Function that tests each element.
thisObject - The object to use when executing the callback.
Return value
If an element passes the test, it returns true, otherwise it returns false.
Example
function isBigEnough(element, index, array) { return (element >= 10); } var retval = [2, 5, 8, 1, 4].some(isBigEnough); console.log("Returned value is : " + retval ); var retval = [12, 5, 8, 1, 4].some(isBigEnough); console.log("Returned value is : " + retval );
Output
[Related recommendation: "vue.js tutorial"]
The above is the detailed content of What is the role of some in es6. For more information, please follow other related articles on the PHP Chinese website!