Object Defenitions

by Serhioromano

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<div id="message1"></div>
<div id="message2"></div>

JavaScript

(function ($) {

    function Base(options) {
        this.sp = $.extend({}, options);
    }
    
    Base.prototype.result = function() {
        $('#message1').html(JSON.stringify(this.sp));
    }

    window.Base1 = Base;

}(jQuery));

(function ($) {

    function Base(options) {
        this.sp = $.extend({}, options);
        
        this.result = function() {
            $('#message2').html(JSON.stringify(this.sp));
        }
    }

    window.Base2 = Base;

}(jQuery));


var base1 = new Base1({
    'data': 'значение'
});
base1.result();

var base2 = new Base2({
    'data': 'значение'
});
base2.result();