I am trying to learn get and set in JavaScript object for that I tried
function ab(n){this.name=n;};
var c= new ab("abcde");
console.log(c);
Object.defineProperty(c, 'name', {
get: function() {
return name;
},
set: function(Name) {
this.name = Name;
}
});
c.name="xyz";
console.log(c.name);
Here I am first making object using constructor and then using get and set. But i am getting error "Maximum call stack size exceeded". I am not getting the reason of This Error . Thanks for help