首页 > 作文

JavaScript之函数中的this和严格模式

更新时间:2023-04-03 11:17:55 阅读: 评论:0

函数中的this的指向
普通函数中的this全世界最美丽的地方是谁—–window

//普通函数    //    function f1() {    //      console.log(this);    //    }    //   f1();

定时器方法中的this是谁—-window

//定时器中的this    //    tinterval(function () {    //      console.log(this);    //    },1000);

对象.方法中的this是谁—-当前的实例对象

原型对象方法中的this是谁—实例对象

构造函数中的this是谁—–实例对象

    //构造函数    /铁岭师范高等专科学校/    function person() {    //      console.log(this);    //对象的方法    //      this.sayhi=function () {    //        console.log(this);    //      };    //    }    //原型中的方法    //    person.prototype.eat=function () {    //      console.log(this);    //    };    //    var per=new person();    //    console.log(per);    //    per.sayhi();    //    per.eat();

严格模式:

//严格模式:    "u strict";//严格模式    function f1() {      古诗静夜思console.log(this);//window    }   好的画室 fti6开幕式1();

本文发布于:2023-04-03 11:17:53,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/8509807948bd64aa2a732fa86154ebfc.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:JavaScript之函数中的this和严格模式.doc

本文 PDF 下载地址:JavaScript之函数中的this和严格模式.pdf

标签:对象   函数   方法   实例
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图