When using get in an object like this, get works:
var people = {
  name: "Alex",
  get sayHi() {
    return `Hi, ${this.name}!`
    }
};
var person = people;
document.write(person.sayHi);
But with a function I get an error. How to use Getters and Setters in a function like this?
function People2() {
  this.name = "Mike";
  get sayHi() {
    return `Hi, ${this.name}!`;
  }
};
var user = new People2();
document.write(user.sayHi); 
     
     
     
     
    