Created
October 19, 2015 03:18
-
-
Save etoxin/82d79ddfb85d62be2fbe to your computer and use it in GitHub Desktop.
Pass By Reference Parameters
This file contains hidden or 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
var globalVar1 = [5]; | |
var globalVar2 = 5; | |
console.log('before: ' + globalVar1 + ', ' + globalVar2); | |
function myFunction(value1, value2){ | |
value1[0]++; | |
value2++; | |
console.log('inside: ' + value1 + ', ' + value2); | |
} | |
myFunction(globalVar1, globalVar2); | |
console.log('after: ' + globalVar1 + ', ' + globalVar2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment