i have a object in javascript and some already defined functions. but how can i assign those functions to the object attributes. i tried different ways. but no hope.. the snippet is given below
// object
var func = {
a : '',
b : ''
};
// methods
var test1 = function(i) { console.log(i); }
var test2 = function(i) { console.log(i*100); }
i need to assign the test1 to a and test2 to b. i tried like this.
var func = {
a : test1(i),
b : test2(i)
};
obviously the errors i not defined is throwing.. is ther any solution other than the below give sinppet.
var func = {
a : function(i) { test1(i); },
b : function(i) { test2(i); }
};