日期:2014-05-16 浏览次数:20352 次
<html > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript"> var obj = {value:2000}; var value = 100; with(obj){ function foo(){//函数声明 value *= 2; } foo(); } console.log(value); //200 console.log(obj.value); //2000 </script> </head> <body> </body> </html>
<html > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript"> var obj = {value:2000}; var value = 100; with(obj){ var foo = function(){//函数表达式 value *= 2; } foo(); } console.log(value); //100 console.log(obj.value); //4000 </script> </head> <body> </body> </html>