function test() { let arr = [] for(let i = 0 ; i < 10 ; i++) { arr[i] = function(){ document.write(' '+ i); } } return arr } const funarr = test() funarr.forEach((item,index)=>{ item() })