+ 1
don't execute when pass arguments in java-script function
function firstFunc(params) { console.log("first func",params) } var arr=[firstFunc(1),firstFunc(2),firstFunc(3),firstFunc(4)]//it execute here but I want it to execute after when I use arr.map(ele=>ele()}
2 ответов
+ 3
Instead of making a function array why not just use the arguments
function firstFunc(params) {
console.log("first func",params)
}
var arr=[1, 2, 3, 4]
arr.map(ele=>firstFunc(ele))
+ 1
#Toni Isotalo
I am doing that thing:-
--------------------------------
function firstFunc(params) {
console.log("first func")
}
var arr=[firstFunc,firstFunc,firstFunc,firstFunc]
var index=0
arr.forEach(element => {
console.log(index++,":",element,)
element()
});
---------------------------------------------------------
and working fine. now I want it to run with argument if javascript have any option to do that