Skip to content

Instantly share code, notes, and snippets.

@romeoh
Created February 20, 2013 07:58
Show Gist options
  • Save romeoh/4993781 to your computer and use it in GitHub Desktop.
Save romeoh/4993781 to your computer and use it in GitHub Desktop.
by value, by reference
// by value
var ref_1 = "string...";
var test_1 = ref_1;
ref_1 = "none";
console.log(test_1)
// by value : Wrapper Object (String, Number, Boolean)
var ref_2 = new String("hello world");
var test_2 = ref_2;
ref_2 = new String("world");
console.log(test_2)
// by reference
var ref_3 = new Array("one", "two", "three");
var test_3 = ref_3;
ref_3[0] = "1";
console.log(test_3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment