Fiddle here
I'm looking at making some very high level logic into helper functions for curiosity's sake. I would like to be able to execute a function with its parameters in the _if function without having to define something like _callback ahead of time? I feel like I'm missing something here.
var _if = function(predicate,callback){
if(predicate){
callback(); //callback(arguments) is not arguments for callback
}
};
var text = 'some text';
_if(1 > 0,function(){
console.log('hello world'); //hello world
});
_if(1 > 0,function(text){
console.log(text); //undefined
});
//define callback for this situation
var _callback = function(x){
console.log(x);
}
_if(1 > 0,function(){
_callback(text); //some text
});