2 # foreach
4 Iterate over the key value pairs of either an array-like object or a dictionary like object.
6 [![browser support][1]][2]
8 ## API
10 ### foreach(object, function, [context])
12 ```js
13 var each = require('foreach');
15 each([1,2,3], function (value, key, array) {
16 // value === 1, 2, 3
17 // key === 0, 1, 2
18 // array === [1, 2, 3]
19 });
21 each({0:1,1:2,2:3}, function (value, key, object) {
22 // value === 1, 2, 3
23 // key === 0, 1, 2
24 // object === {0:1,1:2,2:3}
25 });
26 ```
28 [1]: https://ci.testling.com/manuelstofer/foreach.png
29 [2]: https://ci.testling.com/manuelstofer/foreach