<script>
}
function tomato(names,prices){
vegetable.call(this,names,prices)//把tomato的参数拿过来给vegetable用
}
var a=new tomato('a',10)
function vegetable(name,price){
this.name=name;
console.log(this.name)}
function tomato(names,prices){
vegetable.call(this,names,prices)//把tomato的参数拿过来给vegetable用
}
var a=new tomato('a',10)
</script>
apply用法:唯一区别就是传参的格式,vegetable.apply(this,[names,prices]),
apply传两个参数,第一个代表this的指向,第二个数组代表传入的参数,
call有n个参数,第一个代表this的指向,剩下的代表传入的参数。