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>
浙公网安备 33010602011771号