1

I'm working on a JavaScript library that gets included in my customers application via a script tag.

Another library they want to include is making changes to the Object.prototype by adding methods setObject and getObject as well as Object.prototype.properties. This interferes with the execution of our code.

I would like to know if it's possible to protect our library for any manipulation of global prototypes, even beyond this specific example.

Fergal
  • 5,213
  • 6
  • 35
  • 44
  • 1
    You could use some code like this: https://stackoverflow.com/questions/8580431/recovering-built-in-methods-that-have-been-overwritten – James Hay Nov 13 '19 at 01:57
  • 1
    It's indefensible to modify `Object` in this way. I'd push back on that customer, strongly. Even if you manage to solve this problem, that other poorly written library is going to create other problems for you. – Brad Nov 13 '19 at 02:46

0 Answers0