当前位置:网站首页>The comparison of every() and some() in JS uses a power storage plan

The comparison of every() and some() in JS uses a power storage plan

2022-07-05 09:48:00 Third shopkeeper 666

Preface

In front end development , Iterative processing of arrays is also a common operation . stay JavaScript There are two common iterative methods in arrays :every() and some(), Both functions are in the JS Iterate on arrays in . Then let's make a detailed comparison every() and some() Use .

One 、every()

1.1every grammar

Basic grammar :arr.every(callback(element[, index[, array]])[, thisArg]);

Parameter Introduction :

1.2、every Definition

every() Method is used to detect whether all elements in an array pass the test of a specified function . What it returns is a bool value .

matters needing attention : If you receive an empty array , This method returns in all cases true. If every return of the callback function is truthy value , return

原网站

版权声明
本文为[Third shopkeeper 666]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140536247534.html