I feel like there's probably something incredibly simple I missed in the MDN docs or something, but I've been digging for a while, and I have no clue.
Is there a way to call a function in a similar way to a method? This is basically what I'm trying to do:
function addItem(itemName, quality, quantity /*, arr*/) {
arr.push([itemName, quality, quantity]);
}
var someArr = [['item', 1, 1]];
someArr.addItem('someOtherItem', 2, 3);
// someArr === [['item', 1, 1], ['someOtherItem', 2, 3]]
Now, mind you, I'm not trying to make a constructor or define a variable as a function. Furthermore, I am fully aware that I could simply add the array as an argument and call the function as normal. What I'm trying to accomplish is running a function in a way that, when notated as an array method, will affect that array in the specified way. How can I do this? Can I do this at all?