SpinTheMic
Pro

Interview practice question

A shared object causes data to leak between users of a function

Frontend Engineering · JavaScript Core · Intermediate

A function returns a default config object, and changes made by one caller unexpectedly appear for other callers. What's wrong?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Same object reference returned/reused.
  • Mutations shared.
  • Return new object each time.
  • Freeze shared defaults.
  • Copy before modifying.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics