<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="../lib/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/angular.js/1.3.6/angular.js"></script>
<script src="https://cdn.bootcss.com/angular.js/1.3.6/angular-route.js"></script>
<title>图灵机器人</title>
<script>
var name = "Top";
var obj = {
name:"My Object",
sayName:function(){
alert(this.name);
}
}
obj.sayName();//My Object
(obj.sayName)();//My Object
(obj.sayName = obj.sayName)();//Top
</script>
</head>
<body>
</body>
</html>
这段代码的第三种写法为什么this指向的是全局变量?这第三种写法等价于怎样的写法,我改怎样去理解第三行的这段写法?谢谢各位大神!!
料青山看我应如是
相关分类