Skip to content

Instantly share code, notes, and snippets.

@joshuaaguilar20
Created February 25, 2019 23:14
Show Gist options
  • Save joshuaaguilar20/79ebe3a3f1c95277752e9dd1cbba35a1 to your computer and use it in GitHub Desktop.
Save joshuaaguilar20/79ebe3a3f1c95277752e9dd1cbba35a1 to your computer and use it in GitHub Desktop.
Function Expressions
"use strict";
``
var a = 2;
(function foo(){ // <-- insert this
var a = 3;
console.log( a ); // 3
})(); // <-- and this
console.log( a ); // 2
var a = 2;
(function foo(){ // <-- insert this
var a = 3;
console.log( a ); // 3
})(); // <-- and this
console.log( a ); // 2
(function test(){
a = 10
console.log(a)
})()
(function IIFE(secondFunction){
secondFunction('some global' )
})(function secondFunction(global){
var a = 3;
console.log(a);
console.log(global)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment