-
-
Save anonymous/68695ffc6d92e0af52751ed47bd2c941 to your computer and use it in GitHub Desktop.
javascript up. public methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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