函数作用域复盘2023-10-12 19:29:34输出的结果是多少?1. //123 <!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <script> var a = 123; function fun(){ alert(a); } fun(); </script> </head> <body></body> </html> 2.//undefined 123 <!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <script> var a = 123; function fun(){ alert(a); var a = 456; } fun(); alert(a); </script> </head> <body></body> </html> 3.//123 456 <!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <script> var a = 123; function fun(){ alert(a); a = 456; } fun(); alert(a); </script> </head> <body></body> </html> 4.//undefined 123 <!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <script> var a = 123; function fun(a){ alert(a); a = 456; } fun(); alert(a); </script> </head> <body></body> </html> 5.//123 123 <!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <script> var a = 123; function fun(a){ alert(a); a = 456; } fun(123); alert(a); </script> </head> <body></body> </html> 上一篇:Vue.js的github案例下一篇:k8s:结合Metrics-Server实现弹性伸缩