Skip to content

Instantly share code, notes, and snippets.

@lenafaure
Created May 18, 2017 12:54
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 lenafaure/15b0e838978344b9695f3c327d50263a to your computer and use it in GitHub Desktop.
Save lenafaure/15b0e838978344b9695f3c327d50263a to your computer and use it in GitHub Desktop.
function myFunction(number1) {
function add(number2) {
/* The number1 variable is accessible from this function,
because number1 has been defined outside of the add function */
return number1 + number2;
}
/* As we saw earlier, add is a function but also a variable;
I can render it as a result of myFunction.
Note that when you return a function without the (),
you are returning the function definition, you are not calling
the function to execute. This allows you to call the function later.*/
return add;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment