Nested Function, Function Closure

function outerFunc(base) {
    var punc="!";

    function returnString(ext) {
        return base + ext + punc;
    }
    
    return returnString;
}

var baseString = outerFunc("Hello ");

alert(baseString("World")); //"Hello World! base is still available.
 

你可能感兴趣的:(function)