Count how many items in an array or an object pass a given tester function.

This function is valid in v2.19.0 to v2.24.2. This function has been downloaded 23 times.


{Array|Object|string} arrOrObj
If this is an array or an object all of the items that pass the tester function will be counted. If this is a string all of the characters that pass the tester function will be counted.
{Function} tester
Function that will take in (1) each value, (2) the corresponding key, and (3) a reference to arrOrObj. If the function returns a true-ish value the count will be incremented.
{boolean=} opt_traverseAll Optional, Default:false
Indicates whether or not all items, including the non-owned ones, should be traversed and included in the count.


The number of times tester returned a true-ish value.

Required Functions

This function directly requires the following functions which are included automatically:

  • forOf()
    Traverses all the characters in a string or all of the items in an array or an object, executing a function on each one.
  • nativeType()
    Gets the native type name of a primitive or an object. Unlike YourJS.typeOf(), the types are solely determined by the system.