ObjectModel
ObjectModel copied to clipboard
How to add custom methods to a Model?
Using for example a ObjectModel, how can I add method or functions to it?
In the following example, how can I add or create the method getColor() so it returns thecolor property of the object davidm ?
const Person = ObjectModel({
name: String,
color: String
})
const davidm = Person({
name: 'David',
color: 'red'
})
console.log(davidm.getColor())
Thank you beforehand 😄