want initialize function get called automatically when object is used
<p>I have following piece of code. In this code, I have a class called <code>func</code>. Inside <code>func</code>, I have 3 functions i.e. <code>init, func1 and func2</code>. Then I am calling init function before <code>return object literal</code>. So what happens is when I create new instance of this class using <code>var f = new func()</code> then it automatically calls the <code>init</code> function so I don't have call it manually. So its like constructor in other object oriented languages when a new instance of a class is created then constructor automatically gets called.</p>

<p>Here is the code</p>

<pre><code>var func = function () {
    var a, b,
        init = function () {
            a = 1;
            b = 2;
        },

        func1 = function () {

        },

        func2 = function () {

        };

    init();

    return {
        func1: func1,
        func2: func2
    };
};

var f = new func();
</code></pre>

<p>Now I want to do the exact same thing as above in following scenario. That is I want the <code>init</code> function get automatically called whenever I call any function inside <code>func</code> object. </p>

<pre><code>var func = {
    init: function () {

    },

    func1: function () {

    },

    func2: function () {

    }
}

func.func1();
</code></pre>

<p><strong>Is it possible to make init function automatically called whenever I call any function inside func object in above scenario? If yes then How?</strong></p>
