js一切都是继承自Object
包括Function,Array,Date等都是继承自Object 而function是Function new出来的对象
new的过程
1.改变了函数内this的指向
2.执行了该函数
3.返回了一个对象
和Object.create过程
function create(o){
var f=function(){}
f.prototype=o;
return new f()
}
js一切都是继承自Object
包括Function,Array,Date等都是继承自Object 而function是Function new出来的对象
new的过程
1.改变了函数内this的指向
2.执行了该函数
3.返回了一个对象
和Object.create过程
function create(o){
var f=function(){}
f.prototype=o;
return new f()
}
相关文章: