User1183902823 posted
tell me how could i call public and private method of a SearchEngine module from out side....need a example. thanks
var SearchEngine = (function ( ) {
//Private Method.
var luckyAlgo = function ( ){
//create one random number.
return Math.floor(Math.random()*11);
}
//Returning the object
return {
//privileged method.
getYourLuckyNumber : function ( ){
//Has access to its private method because of closure.
return luckyAlgo();
}
}
} ) ( );