var Person = {
name: '人类',
age: 100,
speak: function() {
console.log('我的名字是'+this.name+',年龄'+this.age)
}
}
var King = {
name: '海王',
age: 10000,
speak: function() {
console.log('@!#!¥!@¥!#!')
}
}
function Gold(props) {
props = props || {}
this.name = props.name || '上帝';
this.age = 0;
this.speak = function() {
console.log('!')
}
}
Gold.prototype.version = '0.1'
var me = new Object();
me.__proto__ = Person;
me = Object.create(King)
//me = new Gold()
//var you = new Gold()
//console.log(me)
//console.log(me.__proto__ === Object.getPrototypeOf(me)) // true
//console.log(me.__proto__ === Gold.prototype) // true
//console.log(me.__proto__ === you.__proto__) // true
function Man(props) {
props = props || {}
Gold.call(this, props)
this.msg = props.msg
}
// Man 继承 Gold
function F() {}
F.prototype = Gold.prototype;
Man.prototype = new F()
Man.prototype.constructor = Man
console.log(new Gold())
console.log(new Man({msg: '你好啊'}))
console