Assigning defined function to an object attribute in javascript
<p>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</p>

<pre><code>// object
var func = {
 a : '',
 b : ''
};

// methods
var test1 = function(i) { console.log(i); }
var test2 = function(i) { console.log(i*100); }
</code></pre>

<p>i need to assign the test1 to a and test2 to b. i tried like this.</p>

<pre><code>var func = {
 a : test1(i),
 b : test2(i)
};
</code></pre>

<p>obviously the errors <em>i not defined</em> is throwing.. is ther any solution other than the below give sinppet.</p>

<pre><code>var func = {
 a : function(i) { test1(i); },
 b : function(i) { test2(i); }
};
</code></pre>
