Can I put similar methods in an associative aray like this?
var function_hold = {
function1: function(){}
function2: function (){}
};
I
Similarly as you would with any other object-oriented programming language, you group functionality in objects. This works in JavaScript as well.
Your code actually creates an object. Alternatively you can use JavaScript's prototype mechanism.
var Person = function(firstname, surname){
this.firstname = firstname;
this.surname = surname;
}
Person.prototype.getFullName = function(){
return this.firstname + " " + this.surname;
}
You then call it like
var tom = new Person("Tom", "Jackwood");
tom.getFullName();