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.

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


{Array|Arguments|string|Object} a
Array or array-like object or string to traverse.
{Function} fn
Function called on each item in a. The parameters passed are as follows: (1) value, (2) key, (3) a and (4) ender function. The this keyword will contain the number of times the function has been called. The ender function may be used to immediately stop traversing a. 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 if all items in a, including those not owned by a, should be traversed.


The number of times fn was called.

Required Functions

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

  • has()
    Every object descended from Object inherits the hasOwnProperty method. This method can be used to determine whether an object has the specified property as a direct property of that object; unlike the in operator, this method does not check down the object's prototype chain.
  • nativeType()
    Gets the native type name of a primitive or an object. Unlike YourJS.typeOf(), the types are solely determined by the system.

Requiring Function

This function is directly required by the following function:

  • 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.