I want to be able to set new name upon instanciation of a new object. But somehow I got an infinite loop to be happening. I dont know how to fix it.
function Human(opt) {
this.name = opt.name; //this causes ranger error or infinite loop
}
Object.defineProperties(Human.prototype, {
name : {
set : function(val) {
if(name === 'Einstein') {
console.log('Hello Einstein');
}
this.name = val;
},
configurable : false
}
});