Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created January 20, 2016 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conanak99/22a1e75663e87b7fdd7c to your computer and use it in GitHub Desktop.
Save conanak99/22a1e75663e87b7fdd7c to your computer and use it in GitHub Desktop.
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.showName = function() {
console.log(this.firstName + ' ' + this.lastName);
};
}
var psn1 = new Person('Hoang', 'Pham');
// các property khai báo vào biến this có thể bị truy xuất từ bên ngoài
// object không còn bao đóng nữa
psn1.firstName = 'changed';
console.log(ps1.firstName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment