Home > Web Front-end > Vue.js > body text

What is the role of some in es6

WBOY
Release: 2022-04-25 15:16:49
Original
5130 people have browsed it

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)".

What is the role of some in es6

The operating environment of this article: Windows 10 system, ECMAScript version 6.0, DELL G3 computer.

What is the role of some in es6

The some() method tests whether an element in the array passes the test implemented by the provided function.

Syntax

array.some(callback[, thisObject]);
Copy after login

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 );
Copy after login

Output

What is the role of some in es6

[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!

Related labels:
es6
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template