0

address.trans returns [] when theres no transactions pend if(txs === []){ returns a transaction still

Any solutions? Basically registering a "depo" when I never depo'd to the generated wallet.enter image description here

tgdavies
  • 10,307
  • 4
  • 35
  • 40

1 Answers1

0

This should be happening because an array is an object. And two objects even with the same value are not equal in JS because they have different reference.

You can see that below:

let trans = [];
console.log(trans === []);
console.log([] === []);
console.log(trans.length === 0);

Array.prototype.length can be one way to check it:

Tushar Shahi
  • 16,452
  • 1
  • 18
  • 39