Good parts closure

by Joe LeMonnier

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>

JavaScript

var foo = function (  ) {
    var a = 3, b = 5;

    var bar = function (  ) {
        var b = 7, c = 11;

// At this point, a is 3, b is 7, and c is 11

        a += b + c;

// At this point, a is 21, b is 7, and c is 11

    };

// At this point, a is 3, b is 5, and c is not defined
document.write( 'a=',a,'b=',b);
    bar(  );

// At this point, a is 21, b is 5
document.write( 'a=',a,'b=',b);
};

foo();

var quo =function (status) {
    return {
        get_status: function (  ) {
            return status;
        }
    };
};

// Make an instance of quo.

/*var myQuo = quo("amazed");
document.write('<br> myQuo is &nbsp',myQuo);
document.writeln('<br> my status is &nbsp',myQuo.get_status(  ));
var test= quo('baff');
*/
var test=new quo('maxed ');
console.log('myQuo is ',test.get_status());


var level=12;
var hex = level.toString(16);
console.log('level=',level);
console.log('hex=',hex);