new vs object create
by Eugene Manager
JavaScript
const Cat = function() {
this.sound = 'mew'
this.say = function () {
console.log(this.sound)
console.log(this)
}
}
const CatObj = {
sound : 'mew mew from boj',
say : function () {
console.log(this.sound)
console.log(this)
}
}
const Mark = new Cat();
//const Mark2 = CatObj;
const Mark2 = Object.create(CatObj)
//Mark.say = ()=>{ console.log('w')}
//Mark.sound = 'Mark';
//Mark2.sound = 'Mark2';
Mark.__proto__.sound='flower1';
Mark2.__proto__.sound='flower2';
console.log('Mark')
console.log(Mark.sound)
Mark.say()
console.log('Mark2')
console.log(Mark2.sound)
Mark2.say()
//console.log(Mark.__proto__)
// Mark.prototype.say()