Home
← All questions

Object.create vs Object.assign in JavaScript

EasyPremiumJavaScript

JavaScript interview practice: Explain the difference between Object.create and Object.assign with examples.

Answer

  • Object.create(proto, [descriptors]) — creates a new object whose prototype is proto. No own properties are copied; behavior is inherited via the prototype chain.
  • Object.assign(target, ...sources) — copies own enumerable properties from sources onto an existing target (shallow copy) and returns target.
Premium question

Unlock the in-browser editor, test cases, and model solution with Mentoxis Premium.

Unlock with Premium