Skip to content

Stew.forEach()

paige edited this page Nov 14, 2023 · 5 revisions

goes through every entry
type: Function

arguments:

  • func Function:
    goes through every entry and runs the function with the info

sub arguments:

list: pair:

<value Any>
<index Number>


.forEach( (value, index) => { } );

<key String>
<value Any>
<index Number>

.forEach( (key, value, index) => { } );

list: pair:
const { Stew } = require('stews');

let arr = new Stew([ "a", "b" ]);

arr.forEach( (v, i) => {
    console.log(v, i);
});
const { Stew } = require('stews');

let obj = new Stew({ key1: "val1", key2: "val2" });

obj.forEach( (k, v, i) => {
    console.log(k, v, i);
});
"a" 0
"b" 1 
"key1" "val1" 0
"key2" "val2" 1