Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Person(name, surname, yearOfBirth){
- this.name = name,
- this.surname = surname,
- this.yearOfBirth = yearOfBirth };
- Object.defineProperty(Person, 'fullName', {
- get: function(){
- return this.name +' '+ this.surname
- }
- });
- var test = new Person("test", "test", 9999);
- console.log(test.fullName);
- Object.defineProperty(Person.prototype, 'fullName', {
- get: function() {
- return this.name +' '+ this.surname
- }
- });
- this.name = name;
- this.surname = surname;
- this.yearOfBirth = yearOfBirth;
- Object.defineProperty(Person.prototype, 'fullName', {
- get() {
- return `${this.name} ${this.surname}`;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement