Как не писать this в функциях внутри класса?

Мой класс:

  constructor(unit, value, convert_to) {
    this.unit = unit;
    this.value = value;
    this.convert_to = convert_to;
  }
  convertDistance = () => {
    // cm to ...
    if (this.unit === "cm" && this.convert_to === "m") {
      console.log(this.value);
      this.value = this.value / 100;
      console.log(this.value);
    } else if (this.unit === "cm" && this.convert_to === "ft") {
      this.value = this.value * CM_TO_FT;
    } else if (this.unit === "cm" && this.convert_to === "in") {
      this.value = this.value * CM_TO_IN;
    }

Как мне деструктурировать или что сделать чтобы не писать this внутри функции


Ответы (0 шт):