Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created January 20, 2016 22:19
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/f213e6b5f7395b825898 to your computer and use it in GitHub Desktop.
Save conanak99/f213e6b5f7395b825898 to your computer and use it in GitHub Desktop.
function Person(firstName, lastName) {
var fstName = firstName;
var lstName = lastName;
this.setFirstName = function(firstName) { fstName = firstName; };
this.getFirstName = function() { return fstName; };
this.setLastName = function(lastName) { lstName = lastName; };
this.getLastName = function() { return lstName; }
}
var psn1 = new Person('Hoang', 'Pham');
console.log(ps1.fstName); // Undefined, không thể truy cập được
console.log(ps1.getFirstName()); // Hoang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment