为了账号安全,请及时绑定邮箱和手机立即绑定

js中call的详细介绍

js中call的详细介绍

回首忆惘然 2018-07-09 10:08:31
<script type="text/javascript">    function Animal() {        this.name = "Animal";        this.Say = function () {            console.log(this);            console.log(this.name);        }    }    function Cat() {        this.name = "Cat";    }    var animal = new Animal();    var cat = new Cat();    //animal.Say();    animal.Say.call(cat);是不是 .调用animal.Say里面的this已经切换到指向cat对象,所以console.log(this);打印了catconsole.log(this.name); 打印了cat这个call好懵逼呀,到底是什么东西..我实在搞不懂能不能来个例子 或者给我解释一下 , ,谢谢了
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 325 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号