1.var 变量 <script type="text/javascript"> var a = "hong"; var fun = function () { var a = "aa"; console.log(a); } console.log(a); //hong fun(); //aa </script> 有局部变量与全局变量同名,在方法内优先使用局部变量 <script type="text/ja…
函数的应用: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> function f(){ alert(this.x); } var x = 1; var a = { x :2 } a.f2…