public

each()Method

Description

Loops through an array or object, calling a function for each element.

Parameters

Type Name Description
Object | Array object the object or array to iterate
Function fn the function to call for each element note that the loop terminates at once if the function returns false
Object [context = object] object to use as 'this context' for the callback function

Return Value

Type: Object | Array

the passed object or array

Example

 var myNumber = 0;
 var myFunction = function(value, key, object) { myNumber++ };
 var myArray = [ 6, 7, 8 ];
 var myObject = { a: 3, b: 4, c: 5 };

 nokia.mh5.each(myObject, myFunction, this);
 // myNumber is 3 now
 nokia.mh5.each(myArray, myFunction);
 // myNumber is 6 now