JSFiddle - React, Tailwind, and code Playground
by Matt Ball
JavaScript
var Person = function () {
var _firstName, _lastName
var _self = {
firstName: function (n) {
_firstName = n
return this
},
lastName: function (n) {
_lastName = n
return this
}
}
Object.defineProperty(_self, "fullName", {
get: function () {
return _firstName + ' ' + _lastName;
}
});
return _self;
}
var x = new Person().firstName('bob').lastName('dole');
console.log(x.fullName); // always undefined