4 执行环境可以访问什么变量
具体可以访问变量类型:局部变量、参数、函数、外部环境变量
优先级:局部变量 > 函数 > 参数 > 外部环境变量
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>08-执行环境可以访问的变量信息</title> 6 7 <script type="text/javascript"> 8 //变量在当前、内部、深层环境都会起作用 9 10 var name="cat"; 11 function f1(){ 12 var age=5; 13 function f2(){ 14 var color="yellow"; 15 function f3(){ 16 console.log("f3:"+name+"--"+age+"--"+color);//f3:cat--function age(){}--yellow 17 function age(){} 18 } 19 f3(); 20 } 21 f2(); 22 } 23 f1(); 24 </script> 25 </head> 26 <body> 27 28 </body> 29 </html>