I am trying to understand Javascript concepts from https://developer.mozilla.org/en-US/docs/JavaScript/A_re-introduction_to_JavaScript . Please see the code below;
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;
}
I am confused why function personFullName() is called like
this.fullName = personFullName;
why it is not called like;
this.fullName = personFullName();
And same for the below;
this.fullNameReversed = personFullNameReversed;
I know functions are objects in javascript but i am unable to understand this concept?