yoklainterview sim

Frontend Javascript Runtime Apis Interview Questions

75 verified Frontend Javascript Runtime Apis interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Javascript Runtime ApisDifficulty 1
What is the main advantage of Map over a plain object when you need to use non-string values as keys?
  • aMap automatically converts keys to strings, just like objects
  • bMap allows any value (objects, functions, numbers) to be used as a key without coercion
  • cMap only accepts numeric keys, which makes lookups faster
  • dMap keys are always converted to Symbols internally
Explanation:A plain object coerces every key to a string (or Symbol), so obj[{}] and obj[1] both end up as string keys. Map keeps keys as-is — an object reference, a number, a boolean, even NaN — with no coercion. Option (a) describes object behavior, not Map's advantage. Option (c) and (d) are simply false.
Javascript Runtime ApisDifficulty 1
const user = { name: 'Ada', address: { city: 'London' } };
console.log(user.address?.city);
console.log(user.contact?.email);

What does this print?
  • aundefined then undefined
  • bLondon then throws a TypeError
  • cLondon then undefined
  • dthrows a TypeError on the first line
Explanation:user.address exists, so ?.city just reads city normally → 'London'. user.contact is undefined, so ?.email short-circuits instead of throwing and evaluates to undefined — this is exactly what optional chaining is for: avoiding a manual user.contact && user.contact.email check.
Javascript Runtime ApisDifficulty 1
function getPort(config) {
  return config.port ?? 8080;
}
console.log(getPort({ port: 0 }));
console.log(getPort({}));

What does this print?
  • a0 then 8080
  • b8080 then 8080
  • c0 then undefined
  • d8080 then undefined
Explanation:?? (nullish coalescing) only falls back to the right-hand side when the left side is null or undefined0 is neither, so config.port ?? 8080 correctly returns 0 for the first call. For {}, config.port is undefined, so it falls back to 8080. This is the classic case where || would have been a bug, since 0 || 8080 would incorrectly produce 8080.
Javascript Runtime ApisDifficulty 1
const original = [1, 2, 3];
const copy = [...original];
copy.push(4);
console.log(original.length, copy.length);

What does this print?
  • a4 4
  • b3 3
  • c4 3
  • d3 4
Explanation:The spread operator [...original] creates a new array with the same elements copied in — copy and original are separate arrays after this. Pushing to copy only changes copy's length (4), while original stays untouched at length 3.
Javascript Runtime ApisDifficulty 1
What is the defining feature of a Set in JavaScript?
  • aIt stores key-value pairs like Map, but with faster lookup
  • bIt stores only unique values and preserves insertion order when iterated
  • cIt automatically sorts its values in ascending order
  • dIt can only hold primitive values, not objects
Explanation:Set is a collection of unique values — adding a duplicate is a no-op — and iterating it (via for...of, spread, or .forEach) yields values in insertion order. It does not sort values, and it can hold objects as well as primitives, so (c) and (d) are wrong. (a) confuses Set with Map.
Javascript Runtime ApisDifficulty 1
const point = { x: 1, y: 2, z: 3 };
const { x, ...rest } = point;
console.log(x, rest);

What does this print?
  • a1 { x: 1, y: 2, z: 3 }
  • bundefined { y: 2, z: 3 }
  • c1 { y: 2, z: 3 }
  • d{ x: 1 } { y: 2, z: 3 }
Explanation:In object destructuring, x pulls out the x property (1), and ...rest collects everything else that wasn't already destructured into a new plain object { y: 2, z: 3 }. x itself is bound to the primitive value 1, not an object.

Test yourself against the 2925-question Frontend bank.

Start interview