Call instances of custom object with different parameters
<p>I want to call an instance of a custom object twice with one parameter different, the problem is if I set its config property it changes accordingly if I create 2 instances, but if I don't specify the property when calling the second instance of the object, it inherits the set parameter from the first instance.</p>

<p>I want the second instance to use the default parameter unless it is manually set when calling it.</p>

<p>I tried making an elem variable and prepend it to queried elements but it didn't work.</p>

<p>HTML:</p>

<pre><code>&lt;div class="parent"&gt;
&lt;div class="test"&gt;&lt;p&gt;test&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;div class="parent-second"&gt;
&lt;div class="test"&gt;&lt;p&gt;test&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>JS:</p>

<pre><code>(function() {

// Utility
if ( typeof Object.create !== 'function' ) {
    Object.create = function( obj ) {
        function F() {};
        F.prototype = obj;
        return new F();
    };
}

var objTest = {

    config: {
        value: 'some text'
    },

    init: function(elem, config) {

        var self = this;
        this.elem = elem;

        $.extend(this.config, config);

        this.doIt();
    },

    doIt: function() {
        var self = this;
        $(self.elem + ' .test p').text(this.config.value);
        console.log($(self.elem + ' .test p'));
    }

};

var parent = Object.create( objTest );

parent.init('.parent', {
    value: 'first div text'
});

// if you comment out the value parameter from the following instance, it will inherit from previous object instance
var parentSecond = Object.create( objTest );

parentSecond.init('.parent-second', {
    value: 'second div text'
});




})(); // end self invoking function
</code></pre>
