Javascript Grammar

A small detail

do not run the browser side first, try to give the output of the following code and explain it.

related codes

let pre = "Bob";
let full = pre + " angel";
class Person {
  construct() {}

  get preName() {
    console.log("preName getter!");
    return pre;
  }

  set preName(value) {
    pre = value;
    console.log("preName setter!");
  }

  get fullName() {
    console.log("fullNmae getter!");
    return full;
  }

  set fullName(value) {
    full = value;
    console.log("fullName setter!");
  }
}

let myName = new Person();
myName.preName = "Linda";
console.log(myName.preName);
console.log(myName.fullName);

what result do you expect? What is the actual running result?

Jul.10,2022

must be looking forward to

"Linda"
"Linda angel"

is actually

"Linda"
"Bob angel"

because you did not reset full. Full does not change because of changes in pre. Full should be modified in set preName .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be7ce3-318c5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be7ce3-318c5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?