2021年1月17日星期日

JavaScript get set. change set

Why dont firsname set? where is error?

const person = {      firstName: "Yasar",      lastName: "KEMAL",    }    Object.defineProperty(person, "fullName", {       get function() { //get sadece okuduğu için kısa kod.          return this.firstName + " " + this.lastName      },      set function(value) { //change name set error          const parts = value.split(' ');          this.firstName = parts[0];          this.lastName = parts[1];      }  })    Object.defineProperty(person, "age", {           value: 50,          writable: true       })    person.age = 60;  person.fullName = "Kemalettin TUĞCU" //send name set error    console.log(person);
https://stackoverflow.com/questions/65767533/javascript-get-set-change-set January 18, 2021 at 08:48AM

没有评论:

发表评论