const o = { vals: [1, 2, 3], sum() { let total = 0; this.vals.forEach(function(v) { total += v; }); return total; } }; console.log(o.sum());