Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var person = {
- _name: "Mykola",
- bday: 8
- };
- Object.defineProperty(person, "name", {
- get: function() {
- return this._name;
- },
- set: function(newValue){
- if(newValue !== this._name) {
- this._name = newValue + " modified by setter";
- this.bday = bday + 1;
- }
- }
- });
- person.name = "Steven";
- console.log(person.name);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement