JSFiddle - React, Tailwind, and code Playground
JavaScript
var helloEC5 = function () {
this.firstName = 'Seeya';
this.lastName = 'Latir';
Object.defineProperty(this, 'fullName', {
get: function () {
console.log('get!');
return this.firstName + ' ' + this.lastName;
},
set: function (value) {
console.log('set');
var words = value.toString().split(' ');
this.firstName = words[0] || '';
this.lastName = words[1] || '';
}
});
};
var a = new helloEC5();
console.log(a.fullName);
console.log(a.firstName);
console.log(a.lastName);
a.fullName = 'John Doe';
console.log(a.fullName);
console.log(a.firstName);
console.log(a.lastName);