码迷,mamicode.com
首页 > 编程语言 > 详细

理解javascript的对象

时间:2017-04-06 19:43:03      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:ase   tail   lun   type   char   http   body   UI   cti   

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<script type="text/javascript">
var life = {};
for(life.age = 1; life.age <= 3; life.age++)
{
switch(life.age)
{
case 1: life.body = "卵细胞";
life.say = function(){alert(this.age+this.body)};
break;
case 2: life.tail = "尾巴";
life.gill = "腮";
life.body = "蝌蚪";
life.say = function(){alert(this.age+this.body+"-"+this.tail+","+this.gill)};
break;
case 3: delete life.tail;
delete life.gill;
life.legs = "四条腿";
life.lung = "肺";
life.body = "青蛙";
life.say = function(){alert(this.age+this.body+"-"+this.legs+","+this.lung)};
break;
};
life.say();
}
</script>
</script>

</body>
</html>

理解javascript的对象

标签:ase   tail   lun   type   char   http   body   UI   cti   

原文地址:http://www.cnblogs.com/jflover/p/6674964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!