Sobes.tech
Junior — Senior

Loss of context when passing an object's method function

livecode

Task condition

What output will appear in the console if the function fun() is called after the getRoles method has been detached from the object?

const user = {
  name: "Bob",
  roles: ["friend", "brother", "student"],
  getRoles: function () {
    return this.roles.map((role) => {
      return this.name + " is " + role;
    });
  }
};

const fun = user.getRoles;