<script> var scope='hello'; function a(){ console.log(scope); //undefined var scope='world'; console.log(scope); //world console.log(b); //undefined for(var i=0;i<4;i++){ var b=i; console.log(b); //0 1 2 3 } console.log(b); //3 } a(); </script>
<script> var scope='hello'; function a(){ console.log(scope); //undefined var scope='world'; console.log(scope); //world console.log(b); //undefined for(var i=0;i<4;i++){ var b=i; console.log(b); //0 1 2 3 } console.log(b); //3 } a(); </script>