0

I was wondering what would be the best way to track changes made to the global namespace by some external javascripts. For example, lets say I have a website and I would like to know which object are being added to the global namespace by some third party software that is running on a visitor's machine. Also is there a way to preserve global namespace from these changes ?

demonius
  • 3
  • 3

1 Answers1

0

ES5 has Object.freeze for 'preserving' objects:

Object.freeze(window);
Object.freeze(Object);
Object.freeze(Object.prototype);

Etc.

ES6's proxy API will allow you to track changes to objects, but the specification is still being drafted. SpiderMonkey has a prototype implementation.

1983
  • 5,882
  • 2
  • 27
  • 39