Skip to main content
JavaScript Interview Questions Predict Output P0 Medium

JSON.stringify · object vs array

Predict the serialized strings and the type of the top-level result.

Official Reference

Code Snippet

const sample = { keep: null, omit: undefined };
console.log(JSON.stringify(sample));
console.log(JSON.stringify([sample.omit, , sample.keep]));
console.log(typeof JSON.stringify(sample.omit));

Expected Output & Explanation

{"keep":null}
[null,null,null]
undefined

Undefined object property values are omitted, while holes and undefined array entries serialize as null. Stringifying top-level undefined returns actual undefined rather than a JSON string.

Module Context & References

JavaScript · Language output drills Trace closures, receivers, prototypes, coercion and array edge cases
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.