Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. function Person(name, surname, yearOfBirth){
  2. this.name = name,
  3. this.surname = surname,
  4. this.yearOfBirth = yearOfBirth };
  5.  
  6. Object.defineProperty(Person, 'fullName', {
  7. get: function(){
  8. return this.name +' '+ this.surname
  9. }
  10. });
  11.  
  12. var test = new Person("test", "test", 9999);
  13. console.log(test.fullName);
  14.  
  15. Object.defineProperty(Person.prototype, 'fullName', {
  16. get: function() {
  17. return this.name +' '+ this.surname
  18. }
  19. });
  20.  
  21. this.name = name;
  22. this.surname = surname;
  23. this.yearOfBirth = yearOfBirth;
  24.  
  25. Object.defineProperty(Person.prototype, 'fullName', {
  26. get() {
  27. return `${this.name} ${this.surname}`;
  28. }
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement