Saturday, September 27, 2014

Ahhh.. javascript functions in scope of a function

Did you know? You can create a function in the scope of a function.
function doSomething(options,aName, bName}{
    function internalFun(a,b){
        return (a+b)/2;
    };

    //or pass a function into a function
    var r = internalFun(options.a,options.getB());

    //but that assumes options implements getB and has a prop of a
    var s = internalFun(optiAonse], options[bName]);

}

No comments:

Post a Comment