miliko0022
@miliko0022
Краткие личные сведения, включая интересующую вас

Почему не меняется prototype у Triangle?

let shape = {
  type: 10,
  getTyp() {return "triangle"}
};

function Triangle(a, b, c) {
  this.a = a;
  this.b = b;
  this.c = c;
  this.getPerimeter = () => this.a + this.b + this.c;
}

Object.setPrototypeOf(Triangle, shape);
let t = new Triangle(1, 2, 3);
console.dir( t.type); //undefined я ожидаю 10
console.dir( shape.isPrototypeOf(t));//false я ожидаю true
console.dir( t.getPerimeter());//6 ok
console.dir(t.getType());//t.getType is not a function я ожидаю   "triangle"


Почему не меняется prototype у Triangle?
  • Вопрос задан
  • 57 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы