If I have
var function_holder = {
someFunction: function () { }
};
How do I call someFunction.
Also is there a way to write someFunction outside of function_holder?
Thanks
If I have
var function_holder = {
someFunction: function () { }
};
How do I call someFunction.
Also is there a way to write someFunction outside of function_holder?
Thanks
call it:
function_holder.someFunction()
This will execute the function like the others say.
I think I have an idea what you mean by "write someFunction outside of function_holder?"..
var theFunc = function(){};
function_holder = {};
function_holder.someFunction = theFunc;
There are lots of ways to do anything in javascript.
There are a couple different ways to do what you want to do.
function function_holder() {
this.my_function = function() {};
};
You would call this by instantiating function holder as such.
var fc = new function_holder();
fc.my_function();
Or alternatively you could do it this way.
function function_holder() {};
function_holder.prototype.my_function = function() {};
You would call this the following way:
function_holder.my_function();
function_holder is an object and new <Object> throws a type error