热门

最新

红包

立Flag

投票

同城

我的

发布
yyzsyx
阿迷创客
5 年前
trueyyzsyx

深圳机场特别待遇,自费哦

CSDN App 扫码分享
分享
4
点赞
打赏
  • 复制链接
  • 举报
下一条:
call()与apply() 的区别 以及Math.max和Math.min function Student(name){ this.name=name this.showInfo=function(){ console.log(this.name) } this.abc=function(a,b,c){ console.log(a,b,c) console.log(this.name) } } var s1=new Student("王一") var s2=new Student("王二") s1.showInfo() s2.showInfo() //call(对象,参数)方法 可以用于改变this的指向 //参数1:替换对象1中this //参数2-n:方法对应的参数 s1.abc.call(s2,2,3,4) //console.log(s1.abc()) //.apply(替换的对象,参数数组) 可以用于改变this的指向 //参数1:替换的对象 //参数2:参数数组 s1.showInfo.apply(s2,null) s1.abc.apply(s2,[1,2,3]) //Math.max,Math.min var arr=[1,2,3,4,5] var max=Math.max.apply(null,arr) var min=Math.min.apply(null,arr) console.log(max) console.log(min)
立即登录