close
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>index15-5</title>
<script type="text/javascript">
var Msg = "Hello, This in outside of Func1()."
alert(Msg); //呼叫函式外的變數Msg
Func1(); //因呼叫Func1函式,函式內又重心宣告一個Msg變數,所以呼叫函式內的Msg變數
alert(Msg); //呼叫函式外的變數Msg
function Func1(){
var Msg = "Hello,This is inside of Func1()."
alert(Msg);
}
</script>
</html>
即便使用相同的名稱做區域變數,JS一樣能夠正確的區分
全站熱搜
留言列表