<script> alert(a); var a = 1; alert(a); function a() { alert(2) ; } alert(a); var a = 3; alert(a); function a() { alert(3); } alert(a);
//结果: function a() { alert(3); } 1 1 3 3 </script>
<script> var a = 1; function fn(){ alert(a); a = 2; } fn(); alert(a);
//结果 1 2 </script>
<script> var a = 1; function fn(a){ alert(a); a = 2; } fn(); alert(a);
//结果: undefined 1 </script>
<script> console.log(num); var num = 24; console.log(num); func(100,200); function func(num1,num2){ var total = num1 + num2; console.log(total); } //结果: undefined 24 300 </script>
<script> fn(); function fn(){ console.log(1) } fn(); var fn = 10; fn(); function fn(){ console.log(2) } fn(); //结果: 2 2 fn is not a function </script>