函数的值

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
//变量作用域
var x=1;
function test(){
document.write('函数体内x的值为:'+x+'<br/>'); //undefined,x值取下面的,但是取不到值
var x=19;
document.write('函数体内对x重新赋值,此时x的值为:'+x+'<br/>'); //19
}
document.write('函数体外x的值为:'+x+'<br/>'); //1
test();
document.write('x的值为:'+x+'<br/>'); //1
//document.write('<hr color="red"/>');

</script>
</body>
</html>

posted @ 2018-08-27 18:19  邓志娇  阅读(209)  评论(0编辑  收藏  举报