1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 </head> 7 <body> 8 9 </body> 10 <script> 11 /*function outer(){ 12 var a = 1; 13 function inner(){ 14 a++; 15 alert(a); 16 } 17 return inner(); 18 } 19 outer(); 20 outer();*/ 21 22 /*var name = 123; 23 var obj = { 24 name:456, 25 getName:function(){ 26 return this.name; 27 // return function(){ 28 // return this.name; 29 // } 30 } 31 }; 32 alert(obj.getName());*/ 33 34 /*var a = 1; 35 function b(){ 36 a = 2; 37 document.write(a); 38 document.write("<br/>"); 39 function a(){}; 40 } 41 // b(); 42 // document.write(a); 43 var bar = b; 44 alert(bar());*/ 45 var a = 1; 46 47 function a(){ 48 document.write(a); 49 } 50 51 document.write(a); 52 document.write("<br/>"); 53 a(); 54 </script> 55 </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
<script>
/*function outer(){
var a = 1;
function inner(){
a++;
alert(a);
}
return inner();
}
outer();
outer();*/
/*var name = 123;
var obj = {
name:456,
getName:function(){
return this.name;
// return function(){
// return this.name;
// }
}
};
alert(obj.getName());*/
/*var a = 1;
function b(){
a = 2;
document.write(a);
document.write("<br/>");
function a(){};
}
// b();
// document.write(a);
var bar = b;
alert(bar());*/
var a = 1;
function a(){
document.write(a);
}
document.write(a);
document.write("<br/>");
a();
</script>
</html>