Last active
February 22, 2017 16:04
-
-
Save rgeraldporter/3f94db1d0b5515789c9675cb659b7cc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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