Friday, 3 May 2013

Javascript private functions

var MyThingy = (function() {
function doSomethingCool() {
//do something
}
function internalSomething() {
//private function because we dont return it from the bottom return
}
function anotherNiftyThing() {
// Note that within the scoping function, functions can
// call each other direct.
doSomethingCool();
internalSomething();
}
//The function it will return alny these funvtions all the other are private and u can't use them when u instansiate the object
return {
doSomethingCool: doSomethingCool,
anothrNiftyThing: anotherNiftyThing
};
})();
view raw gistfile1.js hosted with ❤ by GitHub

No comments:

Post a Comment