Nullish Coalescing (??) — JS Technical Interview Questions & Answers
Fallback only for null/undefined, unlike ||.
Nullish Coalescing (??)
- Nullish Coalescing (??) (js) is a JS topic. In plain words you use it for a short Nullish Coalescing ?? js example in a script in the browser. Don’t start with a slogan — start with that picture.
- Smallest example: the smallest Nullish Coalescing ?? js example you can type. Type it, run it, and say what you see. If you can do that from memory, you know Nullish Coalescing (??) (js).
- From the example next to this theory: Fallback only for null/undefined, unlike ||.
- Trap: only saying “Nullish Coalescing ?? js” with no example. Fix that before you talk about advanced JS.
- Viva: what is Nullish Coalescing (??) (js)? Then show the smallest Nullish Coalescing ?? js example you can type. Then name the trap.
Technical Interview Tip: What is Nullish Coalescing (??) (js)? Show this: the smallest Nullish Coalescing ?? js example you can type. Trap: only saying “Nullish Coalescing ?? js” with no example.
Code Examples for Nullish Coalescing (??)
Nullish Coalescing (??) — working example
const add = (a, b) => a + b;
const name = "Ada";
console.log(`Hi, ${name}!`);
const user = { name: "Lin", city: "Pune", skills: ["CSS"] };
const { city, ...rest } = user;
const skills = [...user.skills, "JS"];
console.log(add(2, 3), city, rest, skills);
console.log(user.profile?.bio ?? "n/a");Nullish Coalescing (??) — modern JS: arrows, template strings, destructuring, spread/rest, ?. and ?? for safe defaults.
How to Explain Nullish Coalescing (??) to an Interviewer
What is Nullish Coalescing (??) (js)?
Used for a short Nullish Coalescing ?? js example a script in the browser Not just the heading
Give one small example of Nullish Coalescing (??) (js).
the smallest Nullish Coalescing ?? js example you can type Fallback only for null/undefined, unlike ||
What mistake do beginners make with Nullish Coalescing (??) (js)?
only saying “Nullish Coalescing ?? js” with no example Show the fix
Where do you use Nullish Coalescing (??) (js)?
a script in the browser a short Nullish Coalescing ?? js example