Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. var person = {
  2. _name: "Mykola",
  3. bday: 8
  4. };
  5.  
  6. Object.defineProperty(person, "name", {
  7. get: function() {
  8. return this._name;
  9. },
  10. set: function(newValue){
  11. if(newValue !== this._name) {
  12. this._name = newValue + " modified by setter";
  13. this.bday = bday + 1;
  14. }
  15. }
  16. });
  17.  
  18. person.name = "Steven";
  19. console.log(person.name);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement