标签:sha org shanghai pre script var w3c oct UNC
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>js作用域</title>
</head>
<body>
<!--在py中:模块,函数,类有自己的作用域-->
<script>
c=‘beijing‘;
f=function(){
var c=‘shanghai‘;
function inner(){
console.log(‘456‘+c);
}
return inner;
};
f()();
function bar(){
console.log(‘123‘+c)}
f=function(){
c=‘shanghai‘;
return bar;
};
f()()
//运行结果;456shanghai
// 123shanghai
</script>
</body>
</html>
标签:sha org shanghai pre script var w3c oct UNC
原文地址:https://www.cnblogs.com/startl/p/12283483.html