es6中some的作用是什么
时间:2022-04-19 14:56
在es6中,some的作用是检测数组中是否存在指定条件的元素;若存在指定的元素则返回的结果是true,若不存在指定的元素则返回的结果是false,语法为“array.some(回调函数),thisValue)”。 本文操作环境:windows10系统、Vue2.9.6版,DELL G3电脑。 some()方法测试数组中的某个元素是否通过了由提供的函数实现的测试。 语法 参数细节 callback - 测试每个元素的函数。 thisObject - 执行回调时用作此对象的对象。 返回值 如果某个元素通过了测试,则返回true,否则返回false。 例 输出 【相关推荐:《vue.js教程》】 以上就是es6中some的作用是什么的详细内容,更多请关注gxlsystem.com其它相关文章!es6中some的作用是什么
array.some(callback[, thisObject]);
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 );