'Why does the function returns 'undefined undefined' instead of name (James Bond)? Its a JS code [duplicate]
function Person(first, last) {
return {
first: first,
last: last,
fullName: function() {
return this.first + ' ' + this.last;
},
fullNameReversed: function() {
return this.last + ', ' + this.first;
}
};
}
p = Person("James", "Bond");
var fullName = p.fullName;
fullName();
I was expecting Output = 'James Bond' but get 'undefined undefined'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
