https://www.quora.com/What-does-the-return-keyword-do-in-JavaScript/answer/Andrew-Webster-16
Last active
October 10, 2015 17:46
-
-
Save arieljatib/5558f6e9357cb9e77b47 to your computer and use it in GitHub Desktop.
JavaScript : The Return
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
// You can set a variable to a function like this: | |
function myFunc(){ | |
var foo= 500; | |
// foo is declared inside the function so it cannot be accessed outside of the function. | |
return foo; | |
} | |
var a = myFunc(); | |
console.log(a); //500 |
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
// If you declare the variable outside the function, you can then change the value inside the function, like so: | |
var foo = 0; | |
function myFunc(){ | |
foo= 500; | |
} | |
myFunc(); | |
console.log(foo); //500 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment