this
JS-0105 9 // Do nothing
10 }
11
12 isUpdateNeeded(): boolean {13 return false
14 }
15}
5 // Do nothing
6 }
7
8 clear(): void { 9 // Do nothing
10 }
11
1import PersistenceService from './persistenceService'
2
3class NullPersistenceService implements PersistenceService {
4 setUpdateIsNeeded(): void { 5 // Do nothing
6 }
7
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();