Я учусь яваскрипт и проходил через пример здесь: https://developer.mozilla.org/en/A_re-introduction_to_JavaScriptПравильный синтаксис для задания свойства объекта для возврата значения объектной функции?
function personFullName() {
return this.first + ' ' + this.last;
}
function personFullNameReversed() {
return this.last + ', ' + this.first;
}
function Person(first, last) {
this.first = first;
this.last = last;
this.fullName = personFullName;
this.fullNameReversed = personFullNameReversed;
}
var x = new Person('mickey', 'mouse');
document.write(x.fullName());
Почему строки кода
this.fullName = personFullName;
this.fullNameReversed = personFullNameReversed;
вместо
this.fullName = personFullName();
this.fullNameReversed = personFullNameReversed();
Я думал, что мы» re this.fullName
на основе возвращаемого значения personFullName()