Making a Method Globally Accessible in Javascript
given i have the following block of code
(function(){
var mb = {
abc:function(){
//do something
},
xyz:function(width, heigh开发者_如何学Ct, site){
//do something
}
};
})();
how do i make the method mb.abc
accessible from the page, but not mb.xyz
?
var mb = function() {
function xyz(width, height, site){
// not visible outside
}
return {
abc:function(){
//do something
}
};
}();
mb.abc() is public, but mb.xyz() is not.
精彩评论