检查JavaScript对象是否已经实例化

Rol*_*and 1 javascript object

我正在开发一个小游戏,我实例化了一些像这样的对象:

this.polyfills = new Application.Polyfills(this.options);
Run Code Online (Sandbox Code Playgroud)

问题在于,在点击(页面上的某些元素)上它被称为一堆代码,并且我不希望每次都实例化该对象,因为它已经实现了它的目的.我尝试过这样的事情:

this.polyfills = window.Application.Polyfills || new Application.Polyfills(this.options);
Run Code Online (Sandbox Code Playgroud)

但上面显然不起作用:)那么将要采取什么方式去做我刚刚描述的内容?

编辑:在单击时实例化的对象(我称之为类)是这样的:

Application.Level = function(_level, _levels, callback) {

    this.helpers = (this.helpers instanceof Application.Helpers) ? true : new Application.Helpers();

    var self = this,

        _options = {
            levels : {
                count : _levels,
                settings : (_level === undefined || _level === '') ? null : self.setLevelSettings(_level, _levels),
                template : 'templates/levels.php'
            },

            api : {
                getImages : {
                    service : 'api/get-images.php',
                    directory : 'assets/img/'
                }
            }
        };

    this.options = new Application.Defaults(_options);
    this.polyfills = (this.polyfills instanceof Application.Polyfills) ? true : new Application.Polyfills(this.options);

    return this.getImages(self.options.api.getImages.service, { url : self.options.api.getImages.directory }, function(data){
        return (typeof callback === 'function' && callback !== undefined) ? callback.apply( callback, [ data, self.options, self.helpers ] ) : 'Argument : Invalid [ Function Required ]';
    });
};
Run Code Online (Sandbox Code Playgroud)

其中包含通过the定义的属性的集合prototype.那么我想要做的可能是不可能的?!

sol*_*oft 8

关于什么 ?

this.polyfills = this.polyfills || new Application.Polyfills(this.options);
Run Code Online (Sandbox Code Playgroud)