The function
func
in your first option "knows" that the variable
array
has some value. Because this function, announced previously and above )
In the second your variant
array
are known at the time when the charge timer.
You can:function myFunc(arr, func) { arr.forEach( ( ) => { setTimeout( func.bind(null, arr), // bind to the function argument 1000 ) }) } myFunc([1, 2, 3, 4], (a) => { console.log("print the array after each 1 second", a); });
There is agreement that the function of the first parameter is the right value.