Replace slow .bind with manual .create+.apply. Gives up to 19x speed up depending on browser. http://jsperf.com/apply-constructor
6 lines
147 B
JavaScript
6 lines
147 B
JavaScript
(function (Constructor, args) {
|
|
var instance = Object.create(Constructor.prototype);
|
|
Constructor.apply(instance, args);
|
|
return instance;
|
|
});
|