Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

Which method creates a deep copy handling Dates, Maps and circular references?

  1. A Object.assign()
  2. B JSON.parse(JSON.stringify(obj))
  3. C structuredClone(obj)
  4. D Array.from(obj)
Answer

structuredClone(obj)

structuredClone is the modern built-in. The JSON approach is lossy, dropping functions and undefined, converting Dates to strings and throwing on cycles.

All Javascript MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as