How does one go about dynamically creating a function in javascript, but have a variable be "dynamically hardcoded" (?). Preferably without using eval().
I thought this would be the cleanest way to pass async.parallel() a few parameters in nodejs without having to bind objects.
function makeFunction( param1){
return function(){
alert(param1);
}
}
Actual Output from console.log( makeFunction("Hello World") );
return function(){
alert(param1);
}
Desired Output from console.log( makeFunction("Hello World") );
return function(){
alert("Hello World");
}
param1 === "Hello World"
. There is no need to create a function that contains the string literal in its source code, it even would be less performant than the closure.