Name: The perils of console.log It' 06/17/2019

The perils of console.log

It's easy to forget that in Javascript console.log is called asynchronously. That means that variables can be modified after console.log is called and the new values will be called. I had a situation where there was a bug where I was assigning a variable instead of comparing it like:

if (j = 1) instead of

if (j == 1)

Well, that cost me a few hours to track down because I was assuming that my variables were the exact values when console.log was being called. I suppose you could use something like:

await console.log

and then check for stupid assignments.