Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// results from console.log() tested in Chrome 58, Firefox 51, Safari 10.0
// block scope
{
function foo() { return 1; }
}
// returns "1"
console.log( foo() );
// IIFE
(function() {
function foo() { return 2; }
})();
// returns "1"
console.log( foo() );
// now let's go to strict mode, inside an IIFE to isolate the test
(function() {
"use strict";
{
function bar() { return 3; }
}
console.log( bar() ); // throws an error!
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment