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 ?
Asked
Active
Viewed 84 times
0
-
What do you mean by "preserve" ? – epascarello Nov 05 '14 at 14:44
-
By "preserve" I meant how to protect global namespace, maybe prevent adding objects to it and so. – demonius Nov 05 '14 at 14:53
1 Answers
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