首先直接放定义:函数
总结this
1.前提:fun是函数 spa
2.thisArg是在fun函数运行时 指定的this值prototype
1.使用call来继承,新函数使用已经定义好的函数里的方法3d
下面直接上实例 函数b直接使用函数a里的c方法code
<script> function a(){ this.a='a'; this.b='b'; this.c=function() { alert('ccc') } } function b(){ a.call(this) } var d= new b(); d.c(); </script>
2.使用call()函数后 ,this改变指向,而且复制临时函数f,完成函数的继承blog
先来看看函数运行call先后的指向继承
很明显 最开始b函数的this是指向自身,经过call函数改变this指向 ,得到了a函数的属性和方法ip
参考资料get