Skip to content

Instantly share code, notes, and snippets.

@Asher-
Created October 13, 2017 02:40
Show Gist options
  • Save Asher-/16d9056037a173e598a8d7e4dc23809f to your computer and use it in GitHub Desktop.
Save Asher-/16d9056037a173e598a8d7e4dc23809f to your computer and use it in GitHub Desktop.
Object.defineProperty(Object.prototype, 'newWithArray', {
value: function( args_array ) {
function create() {
var factory = this.bind.apply(this, arguments);
return factory;
};
var apply_args = Array.prototype.concat.apply( [this], args_array );
var constructor = create.apply( this, apply_args );
var object = new constructor();
return object;
},
enumerable: false
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment