feach

for each for objects and arrays, with context

Usage no npm install needed!

<script type="module">
  import feach from 'https://cdn.skypack.dev/feach';
</script>

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