Let's say my solidity code is
contract MetaCoin {
uint256 public balance = 0;
function getBalance() public view returns(uint) {
return balance
}
}
Let's say I want to call the getBalance function in my javascript tests; I have 2 ways to do it
const MetaCoin = artifacts.require("MetaCoin");
const metaCoinInstance = await MetaCoin.deployed();
// Way 1 using call
const metaCoinBalance = (await metaCoinInstance.getBalance.call()).toNumber();
// Way 2 without using call
const metaCoinBalance = (await metaCoinInstance.getBalance()).toNumber();
Which way is better and what's the difference between the 2 ways of calling?