Getters and Setters built in support
JavaScript getters and setters are now no different to string or Symbol properties. This means that you can have getters in methods, properties, static properties, configuration, etc.
Example:
const HasFullName = compose({
properties: {
firstName: "",
lastName: ""
},
methods: {
get fullName() {
return this.firstName + " " + this.lastName;
},
set fullName(name) {
var words = name.toString().split(" ");
this.firstName = words[0] || "";
this.lastName = words[1] || "";
}
}
});
const developer = HasFullName();
developer.fullName = "Vasyl Boroviak";
console.log(developer.firstName); // "Vasyl"
console.log(developer.lastName); // "Boroviak"
console.log(developer.fullName); // "Vasyl Boroviak"