Last active
August 29, 2015 14:00
-
-
Save cld-santos/11005743 to your computer and use it in GitHub Desktop.
How closure works guided by code.
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
console.clear(); | |
console.log('init Test'); | |
var globalVar = "global"; | |
function myObject(value){ | |
var test="private"+value; | |
this.testLog = function(){ | |
console.log(test + ":" + globalVar); | |
}; | |
return this; | |
} | |
//When I use the new keyword, I made a new scope, | |
var testObject = new myObject("initialized"); | |
console.log('start Test'); | |
testObject.testLog(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment