SOURCE

/************************************************/
//直接定义
/*var person = {
    name:"long",
    age:25,
    say:function(){
      console.log("my name is "+this.name);
    }
};*/
/*
var person = {}
person.name =  "long";
person.age = 25;*/
/************************************************/
//object构造
/*var person=new Object();
person.name="John";
person.age=50;
person.say=function(){
      console.log("my name is "+this.name);
    }
*/
/************************************************/
//使用对象构造器函数
function person(name,age)
{
    Object.defineProperties(this, {
         name: {
            value: name,
            writable: false
        }, 
        age: {
            value: age,
            writable: false
        }, 


    });
}

person.prototype.say = function()
{
    console.log(this.name+' '+this.age);
} 
person.work = function()
{
    console.log(this.name+"正在工作...");
}

var myFather=new person("John",50);
var aFather=new person("long",22);
myFather.say();
aFather.say();
/************************************************/


































console 命令行工具 X clear

                    
>
console