Created
October 13, 2014 12:15
-
-
Save anova/a7d2e29c2bbd4961f2a8 to your computer and use it in GitHub Desktop.
Javascript module pattern with immediate function call.
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
//http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/#modulepatternjavascript | |
var User = (function(){ | |
var _Name, _Surname; | |
return { | |
getName : function(){ | |
return _Name; | |
}, | |
setName : function(value) { | |
if(value !== undefined){ | |
_Name = value; | |
} | |
}, | |
getSurname : function(){ | |
return _Surname; | |
}, | |
setSurname : function(value) { | |
if( value !== undefined) { | |
_Surname = value; | |
} | |
}, | |
getFullName : function(){ | |
return _Name + ' ' + _Surname; | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment