Question:what is the output of the following code?
class ClassWithGetSet {
  #msg = "hello world";
  get msg() {
    return this.#msg;
  }
  set msg(x) {
    this.#msg = `hello ${x}`;
  }
}

const instance = new ClassWithGetSet();
console.log(instance.msg); 

instance.msg = "cake";
console.log(instance.msg);
 

A hello world hello world 

B hello cake hello world 

C hello world hello cake 

D Compile Error 

+ Answer
+ Report
Total Preview: 12

Copyright © 2024. Powered by Intellect Software Ltd