I'm trying to move the Equity property inline and having trouble with the syntax. What is the correct way to define inline getter properties with this pattern?
Account = function() {
var Number;
var Cash;
var MTMPL;
function Account(number, cash, mtmpl) {
this.Number = number;
this.Cash = cash;
this.MTMPL = mtmpl;
};
// How to define the Equity property inline?
Account.prototype.Equity = {
get: function() {
return this.Cash + this.MTMPL;
}
}
return Account;
}();
var account = new Account("123", 100, 50);
/*
Object.defineProperties(Account.prototype, {
Equity : {
get : function() {
return this.Cash + this.MTMPL;
}
}
});*/
alert(account.Equity);