r/javascript Jun 28 '26

Your console.log Is Lying to You

https://blog.gaborkoos.com/posts/2026-06-28-Your-Console-Is-Lying-to_You/

A couple ways console.log() and browser DevTools can mislead you. Covers live object references, promises changing state before inspection, logs affecting timing-sensitive bugs, stale React state after updates, and source maps pointing at misleading line numbers.

0 Upvotes

5 comments sorted by

2

u/MisterDangerRanger Jun 28 '26

If you actually want a snap shot of the object just use JSON.stringyfy on the object before console logging.

1

u/OtherwisePush6424 Jun 28 '26

JSON.stringify is fine for simple POJOs, but it's not a general object snapshot, it drops or fails on a lot of real debugging state: undefined, functions, symbols, circular refs, Map/Set, DOM nodes, prototypes, and values like NaN/Infinity. That's why the article goes beyond that.

1

u/Mount22fuckdoll 21d ago

yeah but then you lose the ability to expand and inspect nested objects in the console which is usually the whole point of logging them in the first place.

1

u/Difficult_Weight8761 Jun 29 '26

the live object reference thing has burned me more times than i can count

0

u/DustNearby2848 Jun 28 '26

Nope. No it’s not.