Quick and dirty tricks for debugging Javascript 🕵
Chang Wang
3714

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.

Like what you read? Give Thalis Kalfigkopoulos a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.