代码编辑器:
x
1
<p>全局变量计数</p>
2
<script>
3
var counter = 0;
4
function add() {
5
return counter += 1;
6
}
7
8
function myFunction(){
9
document.write(add());
10
}
11
12
myFunction();
13
</script>
14
<p>全局变量计数</p>
<script>
var counter = 0;
function add() {
return counter += 1;
}
function myFunction(){
document.write(add());
}
myFunction();
</script>