console
//参数传递
//ECMA中所有函数的参数都是按值传递的
function test1(){
var bb = 1;
function aa(bb) {
bb = 2;
alert(bb);
};
aa(bb);
alert(bb);
}
//非参传递
function test2(){
var bb = 1;
function aa() {
bb = 2;
alert(bb);
};
aa(bb);
alert(bb);
}
//XX传递
function test3(){
var bb = 1;
function aa(num) {
bb = 2;
alert(bb);
};
aa(bb);
alert(bb);
}
var xxx="global";
if(true){
var xxx="local";
alert(xxx);
}
alert(xxx);
<h1>
<a href="https://www.nowcoder.com/questionTerminal/8e3f169e6199429cb730fe3cd40957b0?mutiTagIds=644&orderByHotValue=1">牛客刷题
</a>
</h1>
<button type="button" onclick="test1()">参数传递</button>
<p id="test1"></p>
<button type="button" onclick="test2()">非参传递</button>
<p id="test2"></p>
<button type="button" onclick="test3()">XX传递</button>
<p id="test2"></p>