How to make a JavaScript object's prototype pe

2019-06-27 10:58发布

问题:

Can I enforce that the prototype of an object not be changed?

Note! There are some requirements:

  • The object should behave just like a regular object literal (add/remove/configure/modify properties and descriptors on the object),
  • with literally the only new limitation being that the prototype is permanent.

So other than the prototype being permanent, I don't want to add any other limitations (tools like Object.seal/freeze/preventExtensions impose more limitations on the object).

Would I have to monkey-patch