const BigBag = { _weight: 0, _capacity: 0, _item : [], set capacity (cap) { this._capacity = cap; } , get items () { return [...this._item]; }, insertItem (item, weight) { this._item.push( {item, weight}) } }; BigBag.capacity = 30; BigBag.insertItem("Blabla", 10); let items = BigBag.items; console.log(items);