Would I want to nest one function into another?
A:
Is this what you're asking?
function add1(x){
return x + 1;
}
function mult2(x){
return x * 2;
}
function add1ThenMult2(x){
return mult2(add1(x));
}
add1ThenMult2(10); // --> 22
or, hiding the 2 functions ...
var add1ThenMult2 = (function(){
function add1(x){
return x + 1;
}
function mult2(x){
return x * 2;
}
function add1ThenMult2(x){
return mult2(add1(x));
}
return add1ThenMult2;
}());
add1ThenMult2(10); // --> 22
z5h
2010-04-15 20:36:37
A:
You might consider jquery-aop for adding advice around or before a given function.
wombleton
2010-04-16 00:25:09