随笔 - 48, 文章 - 0, 评论 - 0, 阅读 - 12375
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

this-纯函数

Posted on   程序员入门到放弃  阅读(83)  评论(0编辑  收藏  举报
复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">

        var name = 'this is window';  //定义window的name属性 
            function getName(){ 
                   console.log(this);    //控制台输出: Window  //this指向的是全局对象--window对象 
                   console.log(this.name);  //控制台输出: this is window  / 
            } 
            
            getName(); //相当 window  window.getName();

    </script>
</body>
</html>
复制代码

努力加载评论中...
点击右上角即可分享
微信分享提示