const createArrOfFunc = length => { let arr = Array.from({ length }, _ => function fn() { return arr.indexOf(fn) }) return arr; } let a = createArrOfFunc(5); alert(a[2]());