SO I have two "name" as a property and as an parameter passed on Object.defineProperty(). If I choose to put naming convention same on as "name" for my book object as well Object.defineProperty() I am getting an error call "Stack size exceeds " on console. What is the exact difference between two? and how does it matters.
var book ={
year: 2004,
edition : 1
};
Object.defineProperty(book, "year",{
get: function(){
return this.year;
},
set:function(newValue){
if(newValue > 2004){
this.year = newValue;
this.edition = this.edition + newValue -2004;
}
}
});
book.year = 2005;
alert(book.edition);
Thank you