Skip to content

Instantly share code, notes, and snippets.

@tfanme
Created October 19, 2013 13:31
Show Gist options
  • Select an option

  • Save tfanme/7055860 to your computer and use it in GitHub Desktop.

Select an option

Save tfanme/7055860 to your computer and use it in GitHub Desktop.
Primitive types are passed by value
// 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