Quick and dirty tricks for debugging Javascript 🕵
Chang Wang
323

Nice article. Always something new to learn.

Regarding the solution with console.log :

console.log(getBaz()) || getBaz() > 1

works well, unless getBaz() returns different values on consecutive calls (e.g. it increments an outer scope counter) in which case the console log will print one value and the condition check will use another.

The print() suggested afterwards solves it, but as an intermmediate solution (no extra function definition), you can always call getBaz() just once:

var cache;
console.log(cache=getBaz()) || cache;

Br.

Show your support

Clapping shows how much you appreciated Thalis Kalfigkopoulos’s story.