javascript this指向
<!DOCTYPE html>
<html lang="zh">
<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>javascript this指向</title>
</head>
<body>
<script type="text/javascript">
var a = {
name: 'mfg'
}
function test() {
console.log(this)
}
test(); //指向window
new test(); //指向test()
test.call(a); //指向a
</script>
</body>
</html>
作者:孟繁贵 Email:meng010387@126.com 期待共同进步!