日期:2014-05-16  浏览次数:20443 次

javascript创建对象的3种方式
var bird_1 = {
id:"id",
name:"name",
getName:function (){return "name";}
};

function bird_2(){
this.id = "id",
this.name = "name",
this.getName = function (){
return "name";
}
}
var bird_21 = new bird_2();

function bird_3(){
var bird = {
id:"id",
name:"name",
getName:function (){return "name";}
}
return bird;
}
function bird_3(){
var bird = new Object();
bird.id = "id";
bird.name = "name";
bird.getNmae = function (){return "name";}
return bird;
}
var bird_31 = new bird_3();