函数的四种调用模式

函数调用

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
  //函数调用    
  // 函数内部的this指向window
    var age=18;
    var p={
        age:15,
        say:function(){
            console.log(this.age);
        }
    }
    var f1=p.say;   //f1是函数
    f1();   //函数调用-->this:window       -->this.age=18
   
 </script>
</html>

  this 的含义:函数内部的this指向window

猜你喜欢

转载自www.cnblogs.com/guangzhou11/p/9116311.html