Skip to content

Instantly share code, notes, and snippets.

@farmanp
Last active July 24, 2016 21:18
Show Gist options
  • Save farmanp/c8cb7be1b3ce2c0d8a682c526ac2544e to your computer and use it in GitHub Desktop.
Save farmanp/c8cb7be1b3ce2c0d8a682c526ac2544e to your computer and use it in GitHub Desktop.
Create a variable outside the global scope
// Create a function that holds another function which will "create" a name
function init(){
// Global variable inside the function to be used after initialization
firstName = "FIRST NAME"
// Second function is what returns the global variable
function createName(n){
return n
}
return createName(firstName);
}
// Run the function
init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment