this 区域 实例 测试

<html>
<body>

<script type="text/javascript">

var oCar = new Object;
oCar.color = "red";

function test(){
   alert(color +"   1");  //undefined
   alert(this.color +"    2");  //undefined
   var color = "    green";
   alert(color +"   3");   //green
   alert(this.color+"   4");  //undefined
}
test();
oCar.showColor = function() {
  alert(this.color+"    5");};  //red

oCar.showColor();

</script>

</body>
</html>

  

posted @ 2016-07-18 17:51  joycefan  阅读(155)  评论(1编辑  收藏  举报