call和 apply的区别是什么?
2016-12-20 本文已影响0人
智多牛
/**
* 父对象
*/
function Father(name)
{
console.log(name)
}
/**
* 使用Call方法
*/
function Boy()
{
Father.call(this,'boy')
}
new Boy()
/**
* 使用Apply方法
*/
function Girl()
{
Father.apply(this,['girl'])
}
new Girl()