function employee(_name, _dept){
this.getName = (function(){ return _name; })();
this.getDept = (function(){ return _dept; })();
}
employee.prototype={ say:'hello' }//父类赋值
var x = new employee('test1',2);//x继承
console.log(x.say);
x.__proto__={say:'hi'};//x改自己的
console.log(x.say);
var y = new employee('test2', 1);//y继承
console.log(y.say);
y.__proto__.say = 'are you ok?';//y改父类的
console.log(y.say);
var z = new employee('test3');//z继承
console.log(z.say);
运行结果
hello
hi
hello
are you ok?
are you ok?