Created
October 13, 2017 02:40
-
-
Save Asher-/16d9056037a173e598a8d7e4dc23809f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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