js 对象的申明方式

<script type="text/javascript">


var person = {
Age: 85,
Name: "wise",
Sex: true,
Eat:function() {

alert("我是人,我会吃饭");

},
Run:function(mes) {

alert("我是人,我会吃饭"+mes);
}
}

person.Eat();//无需创建对象,直接对象.方法调用:

function Dog(mes) {
this.Age = "89";
this.Name = "dog";
this.Sex = true;
this.Eat=function() {
alert(this.Age);
}

}
var dog = new Dog();//需要创建对象再调用
dog.Eat();


</script>

posted on 2015-05-25 15:59  高达  阅读(205)  评论(0)    收藏  举报

导航