1 - Some basic Array every method examples
1.1 - Just a test all for number type example
In this example I am using the array every method to check if a given array contains only numbers or not. This is done by making use of the typeof operator when working out the expression for the function that I pass to the array every method. In the body of this method the first argument will be a value of a current element in the array that is being tested, which is the norm for many array prototype methods such as this.
1.2 - Making an is all number helper
So then the array every method can be used to create methods that will preform a test on all elements in an array and return true of all the elements in that array pass the given test. So I can create a method like all numbs and have it so that I just pass an array, and the all nums helper will return true of all elements in the array are numbers.
2 - The array some method
Another method that is like the array every method is the array some method. This works just like the array every method and many other methods like it in that I can give if a function as an argument that will be called for each element in the array. However when using this array some method the result will be returned true in the every that just one element will resolve as true with the given method.
3 - An Array tester method that can be used in an every or some mode
Still if the aim is to make my own utility module, then there is making some kind of test method that will work like the every method, or some method also maybe. So with that said I took a moment to work out something like this real fast.
4 - Conclusion
There is also maybe taking a moment to edit and expand older posts too while I am at it such as my post on the array for each method, as well as the general concept of the for each method and alternatives. Many of these array prototype methods are just ways of doing things that are not so hard to do with just a while loop, but they are common tasks, and having these methods at the ready can help keep me from repeating code over and over again for these things when they come up.
There are all kinds of other methods that could be made like the every and some methods when it comes to making my own methods, or using some kind of utility method. In lodash there is a lodash every and lodash some method, alone with many other useful array and object methods for example.