Sobes.tech
Back to tasks
Junior — Middle+
34

Поведение this в обычной функции и стрелочной функции

Get help with live coding in real time with Sobes Copilot
Task condition

Что будет возвращено при вызове следующих методов?

function getDiameter() {
  return this.radius * 2;
}

const figure = {
  radius: 10,
  diameter: getDiameter,
  perimeter: () => 2 * Math.PI * this.radius,
};

figure.diameter();  // ?
figure.perimeter(); // ?