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.
This function is valid in
v2.7.0 to v2.18.1.
This function has been downloaded 17 times.
Parameters
{Array|Object|string}
obj
If is an array, an array-like object, or an object, its items will be traversed. If it is a string its characters will be individual traversed.
{Function}
fn
Function to call for each item traversed within obj
. The parameters passed are as follows: (1) value, (2) key, (3) obj
and (4) ender function. The this
keyword will contain the number of times this fn
function has been called. The ender function may be used to immediately stop traversing obj
. Calling the ender function with a true
-ish value will instead make the ender function return a boolean value indicating if the ender function has already been called (useful only in a catch
or finally
clause).
{boolean=}
opt_traverseAll
Optional, Default:false
Boolean indicating whether or not even the properties that are not owned by obj
should be traversed. If true
all properties will be traversed.
Returns
{number}
Number of times fn
was called.
Required Functions
This function directly requires the following functions which are included automatically:
-
forEach()
Traverses all the characters in a string or all of the elements in an array or an array-like object, executing a function on each one.
-
forIn()
Runs through all of the properties of an object, executing a function for each property found.
-
isArrayLike()
Determines if an object is an array or at least array-like.
-
typeOf()
Either gets the type of a value or adds a constructor registering its custom type name.
Requiring Functions
This function is directly required by the following functions:
-
count()
Count how many items in an array or an object pass a given tester function.
-
index()
Indexes the target
object based on the items found in subject
and the callback
function.
-
isFullOf()
Determines if an array, array-like object, or an object is full of items that match a specific type or tester function.
-
modEach()
Takes an array or an object and traverses all of its key/value pairs allowing for modifications while in the end returning a reference to that same array or object.
-
repair()
Creates a object where the keys and values are based on key/value pair returned by the specified pairing function.