Skip to content

Instantly share code, notes, and snippets.

/user.js Secret

Created May 24, 2016
Embed
What would you like to do?
javascript up. public methods
var User = (function() { // IIFE mit Closure
var _firstname;
var _lastname;
function User(firstname, lastname) {
_firstname = firstname;
_lastname = lastname;
}
User.prototype.getFullName = function() {
return _lastname + ', ' + _firstname;
}
return User;
})();
// Beispiel
var user = new User('Max', 'Mustermann');
user._firstname = 'Peter'; // Hat keine Auswirkungen...
console.log(user.getFullName()); // Mustermann, Max
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.