feach
v1.0.0
Published
for each for objects and arrays, with context
Downloads
4
Readme
for each for objects and arrays, with context
var obj = {
fergus: 'is a name',
tom: 'is also a name',
jim: 'not so much...'
}
var array = ['fergus', 'tom', 'jim'];
feach(array, function(thing, i) {
console.log(thing, this[thing]);
}, obj);
feach(obj, function(property, value) {
console.log('property', property);
console.log('has the value', value);
});
// logs
fergus is a name
tom is also a name
jim not so much...
property fergus
has the value is a name
property tom
has the value is also a name
property jim
has the value not so much...