implement-new

new一个函数构造器主要步骤

1
2
3
4
5
function instant(fn,...args){
var obj = Object.create(fn.prototype);
var val = fn.apply(obj,args);
return typeof obj === 'object' ? val : obj;
}