console.log of a large object shows a collapsed tree you have to click open, and JSON.stringify throws on the first cycle and drops undefined. When you debug a config, a store's state or an API response, it often helps to print every key and value as plain text, one per line, indented by depth.
Write printNested(value) in print-nested.js. It walks an object or array at every depth, builds one line per key, logs the whole text with a single console.log, and returns that text.
Each own, enumerable string key gets one line, in Object.keys order: key: value. Symbol keys, inherited keys and array holes are skipped.
A key whose value is a non-empty plain object or array prints key: alone, and its keys follow, indented two more spaces.
Arrays print their indexes as keys (0: …, 1: …).
Strings print as JSON.stringify writes them: in double quotes, with quotes inside escaped.
Every other value prints as String(value) does: 36, NaN, false, null, undefined, Symbol(id), 10 for 10n. Keys whose value is null or undefined are not skipped.
An empty object prints key: {}; an empty array prints key: [].
Only arrays and plain objects (prototype Object.prototype or null) are walked into. A Date prints its toISOString(), or Invalid Date. A Map, a Set or a class instance prints String(value).
An object or array that the walk is already inside of prints key: [Circular]. An object that appears twice without being inside itself is printed in full both times.
The top-level value follows the same rules: {} and [] print as {} and [], and a value that is not a container prints alone ("hi", 7).
console.log is called once, with the returned text.