Is it possible to pass a data property as argument to a method?

I have a component that displays balances for 4 separate tokens. I’d like to have a function like this:

    async updateTokenBalance(token, balance) {
      balance = await getTokenBalance(token);
      balance = balance.value.uiAmount;

which I can call like so:

updateTokenBalance(this.a_acc, this.a_balance);
updateTokenBalance(this.b_acc, this.b_balance);
updateTokenBalance(this.c_acc, this.c_balance);
updateTokenBalance(this.d_acc, this.d_balance);

unfortunately this doesn’t seem to work. The only way I’ve gotten it to work so far is by having 4 separate functions:

    async updateATokenBalance() {
      let balance = await getTokenBalance(this.a_acc);
      this.a_balance = balance.value.uiAmount;
    // the other 3 analogous

in particular, it’s the second line of the original function that doesn’t seem to work if I pass this.a_balance as balance arg:

      balance = balance.value.uiAmount;

Is there a way to make it work?

You can’t pass in this.a_balance as an argument and expect that assigning the argument will also assign to this.a_balance. That’s not how arguments work in Javascript. You’d have to do something like:

async updateTokenBalance(token, balance_type) {
  const balance = await getTokenBalance(token);
  this[balance_type] = balance.value.uiAmount;
  // or if reactivity doesn't work, try: Vue.set(this, balance_type, balance.value.uiAmount)
// call like:
updateTokenBalance(this.a_acc, 'a_balance');
updateTokenBalance(this.b_acc, 'b_balance');

Sort of true. With primitives, yes, with objects passed as arguments you can certainly mutate them.

My approach would be to go more functional:

async updateTokenBalance(token) {
  const res = await getTokenBalance(token);
  return res.value.uiAmount

this.a_balance = await updateTokenBalance(this.a_acc);