Maybe this is a simple question but I could not find anything on google or this site.
So if I have
var myNamespace = {
foo: function() {
},
bar: function() {
}
};
how would i load both foo() and bar() without having to do it one by one, e.g.
<script type="text/javascript">
$(document).ready(function(){
myNamespace.foo();
myNamespace.bar();
.
.
.
});
</script>
I’ve not tested this, but something like this should prove useful.
Every function in JavaScript has a
call()method for invoking it. Then:If you need to replace the
thisscope reference, you could patch this up withjQuery.proxy.