Skip to content

Instantly share code, notes, and snippets.

@etoxin
Created October 19, 2015 03:18
Show Gist options
  • Save etoxin/82d79ddfb85d62be2fbe to your computer and use it in GitHub Desktop.
Save etoxin/82d79ddfb85d62be2fbe to your computer and use it in GitHub Desktop.
Pass By Reference Parameters
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