Проблема с пониманием this
Доброго времени суток,
не могу понять,почему при вызове update.call() в консоль приходит undefined .
const bruce = {name: 'Bruce'};
const madeline = {name: 'Madeline'};
function greet() {
return `Привет ! Меня зовут ${this.name}`;
}
greet.call(bruce);
greet.call(madeline);
function update(birthYear,occupation){
this.birthYear = birthYear;
this.occupation = occupation;
}
console.log(update.call(bruce,1991,'singer'));
console.log(update.call(madeline,1988,'actress'));
:help: |
Потому что ваш метод update ничего не возвращает.
|
Nexus,
а понял, спасибо! |
| Часовой пояс GMT +3, время: 10:25. |