Skip to content

Instantly share code, notes, and snippets.

@vinothbabu
Created September 3, 2012 16: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 vinothbabu/3610375 to your computer and use it in GitHub Desktop.
Save vinothbabu/3610375 to your computer and use it in GitHub Desktop.
call a private function from a string in javascript
var valdiate = (function() {
var _p={};//toss all private members into a single object.
_p.list=[];
_p.init=function(){
_p.list=[];
};
var noDigits = function() {
};
//public members. use "this" to reference object followed by the method.
//however valdiate._p.list won't be accessible to the global scope
return {
check: function() {
noDigits();
},
fnNaMe1:function(){
_p.init();
},
fnName2:function(){
return _p.list.slice(0);//return a clone
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment