below steps is simple example.
setp1 : create a js file named as zms.js
//zms.js
(function(window) {
var zms = window.zms={}; ;
var s = function(){alert("s");}
var d = function(){alert("d");}
var e = function(){alert("e");}
function funcCall(obj, func, context) {
for (key in obj){
if (obj.hasOwnProperty(key)) {
func.call(context, obj[key], key);
}
}
}
function exploseFun(dst,obj) {
funcCall(obj, function(value,key){
dst[key]=value;
});
return dst;
}
//make those function can be called in anywhere by zms.funcName(), e.g. zms.s();
exploseFun(zms, {
's': s,
'd': d,
'e': e
});
})(window);
setp2 : create a html file named as test.html to import zms.js to test
//test.html
<html>
<head>
<script src="zms.js"></script>
</head>
<script>
try{
zms.s();
zms.d();
zms.e();
}catch(e){
alert("eeror");
}
</script>
</html>