Created
May 26, 2017 03:51
-
-
Save gotraveltoworld/257186eb847762a60b8af9cb9938af4c to your computer and use it in GitHub Desktop.
Is JavaScript a pass-by-reference or pass-by-value language?
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
function changeStuff(a, b, c) | |
{ | |
a = a * 10; | |
b.item = "changed"; | |
c = {item: "changed"}; | |
} | |
var num = 10; | |
var obj1 = {item: "unchanged"}; | |
var obj2 = {item: "unchanged"}; | |
changeStuff(num, obj1, obj2); | |
console.log(num); | |
console.log(obj1.item); | |
console.log(obj2.item); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment