课程: JavaScript: Arrays

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Do elements pass a test?

Do elements pass a test?

- [Instructor] Sometimes we need to determine whether or not an array passes a test, sometimes, or every time. Thankfully two array methods exist to help us some and every. These array methods function identically, both return booleans based on whether or not the functions criteria match some or every element in the array. With Some, as the name implies, if at least one element matches the criteria, it will return true. With every, every single element in the array must match the criteria for it to return a true value. The syntax for some and every should look very familiar as we've used this previously with, for each, find and find index,. Both array methods take a callback function that has three parameters. Element which is required, index which references the index of the current element and array, which is the array you're iterating over. This also has a parameter, this Arg, but we're going to keep things simple…

内容