1. 利用json创建对象
var company = {};
company.name= '华为';
company.address = '北京';
company.produce = function(message)
{
alert(message);
}
2.使用JavaScript中的Object类型
company= new Object();
company.name= '淘宝';
company.address = '杭州';
company.produce= function(message)
{
alert(message);
}
3.通过创建函数来生成对象
company = function(){
this.name = '新浪';
this.address = '北京';
this.produce = function(message){
alert(message);
}
}
来源:https://www.cnblogs.com/yanjunwu/archive/2012/09/11/2679736.html