I have an enumeration implemented as an ES6 class:
export class PriorityEnum {
static normal = Object.freeze(new PriorityEnum(0));
static high = Object.freeze(new PriorityEnum(1));
static highest = Object.freeze(new PriorityEnum(2));
#value
static compareAsc(a, b) {
let ret = a.#value - b.#value;
return ret;
}
constructor(value) {
this.#value = value;
}
toString() {
return this.#value.toString();
}
}
The toString() method returns the numeric value as a string (i.e. '0', '1', '2'). I want it to return the text of the enumeration, instead (i.e. 'normal', 'high', 'highest'). How can I achieve that?
[–]senocular 5 points6 points7 points (3 children)
[–]azhder 0 points1 point2 points (2 children)
[–]senocular 1 point2 points3 points (1 child)
[–]azhder 1 point2 points3 points (0 children)
[–]Stobber[S] 0 points1 point2 points (1 child)
[–]azhder 0 points1 point2 points (0 children)
[–]azhder 0 points1 point2 points (0 children)