// For example Define the Product class - the Constructor function
function Product(id, name, price, expiryDate) {
this.id = id;
this.name = name;
this.price = price;
this.expiryDate = expiryDate;
}
// Here, use Object.defineProperty to create property
Object.defineProperty(Product, 'daysToExpire',{
get() {
return this.daysToExpire;
}});
Aucun commentaire:
Enregistrer un commentaire
to criticize, to improve