this
JS-010526 return this.officeNumber;
27 }
28
29 getRole() {30 return 'Manager';
31 }
32}
25 return this.school;
26 }
27
28 getRole() {29 return 'Intern';
30 }
31}
26 return this.github;
27 }
28
29 getRole() {30 return 'Engineer';
31 }
32}
41 return this.email;
42 }
43
44 getRole() { 45 return 'Employee';
46 }
47}
If a class method does not use this
, it can sometimes be made into a static function. If you do convert the method into a static function, instances of the class that call that particular method have to be converted to a static call as well (MyClass.callStaticMethod())
class Person {
sayHi() {
const greeting = document.createElement("div");
greeting.innerText = "Hello!";
document.appendChild();
}
}
const person = new Person();
person.sayHi();
class Person {
static sayHi() {
const greeting = document.createElement("div");
greeting.innerText = "Hello!";
document.appendChild();
}
}
Person.sayHi();