Created
October 19, 2013 13:31
-
-
Save tfanme/7055860 to your computer and use it in GitHub Desktop.
Primitive types are passed by value
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
| // sample 1 | |
| function foo(bar) { | |
| bar = 2; | |
| } | |
| var a = 1; | |
| foo(a); | |
| alert(a); // => 1 | |
| // sample 2 | |
| var a = 1; | |
| var b = a; | |
| b = 2; | |
| alert(a); // => 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment