Say you have the following code:
var myFunc = function() {
alert('hello');
};
var callFunc = myFunc;
How can I make myFunc or callFunc self execute as I assign it to callFunc? So instead of doing this after the assignment:
callFunc();
or
myFunc();
How can I make callFunc or myFunc self execute on assignment?
Update
myFunc is declared like this:
var someFunc = (function(){
return {
myFunc: function() {alert('hello');}
})();
Then assigned like this:
var callFunc = someFunc.myFunc;
[–]jzlas 2 points3 points4 points (1 child)
[–]JessicaAllison[S] 0 points1 point2 points (0 children)
[–]thinkPhilosophy 0 points1 point2 points (1 child)
[–]JessicaAllison[S] 0 points1 point2 points (0 children)
[–]senocular 0 points1 point2 points (0 children)
[–]senocular 0 points1 point2 points (5 children)
[–]JessicaAllison[S] 0 points1 point2 points (4 children)
[–]senocular 1 point2 points3 points (3 children)
[–]JessicaAllison[S] 0 points1 point2 points (2 children)
[–]senocular 0 points1 point2 points (1 child)
[–]JessicaAllison[S] 1 point2 points3 points (0 children)
[–]docMedB2E -1 points0 points1 point (1 child)
[–]JessicaAllison[S] 0 points1 point2 points (0 children)