Skip to content

Instantly share code, notes, and snippets.

@Shinpeim
Created April 7, 2015 15:12
Show Gist options
  • Save Shinpeim/a7966018db2f71d1cab8 to your computer and use it in GitHub Desktop.
Save Shinpeim/a7966018db2f71d1cab8 to your computer and use it in GitHub Desktop.
function Person(firstName, lastName){
this.firstName = firstName;
this.lastName = lastName;
}
var p = new Person("shinpei", "maruyama");
function nyan(p){
p = new Person("tarou", "yamada");
}
nyan(p);
console.log(p.firstName); // shinpei
console.log(p.lastName); // maruyama
function wan(p){
p.firstName = "tarou";
p.lastName = "yamada";
}
wan(p);
console.log(p.firstName); // tarou
console.log(p.lastName); // yamada
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment