Skip to content

Instantly share code, notes, and snippets.

@rgeraldporter
Last active February 22, 2017 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgeraldporter/3f94db1d0b5515789c9675cb659b7cc3 to your computer and use it in GitHub Desktop.
Save rgeraldporter/3f94db1d0b5515789c9675cb659b7cc3 to your computer and use it in GitHub Desktop.
// 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