js apply与call的用法与区别

apply和call

function Person(c, d) {

  return this.a + this.b + c + d 

}

var  o = {a: 1, b: 2}

Person.call(o, 3, 4) 或者 Person.apoly(o, [3, 4]),  o是你想作为Person函数里面this的对象 ,结果都是10

posted @ 2018-07-17 09:36  zph前端  阅读(176)  评论(0编辑  收藏  举报