Last active
October 11, 2015 07:18
-
-
Save clux/3823024 to your computer and use it in GitHub Desktop.
Prevent JavaScript extensions/replacement of native objects because implicit dependencies and evil.js are bad things
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var classes = [Object, Array, String, RegExp, Date, Number, Function]; | |
var nonClasses = [Math, JSON, console]; | |
classes.concat(nonClasses).forEach(function (o) { | |
Object.freeze(o); | |
}); | |
classes.forEach(function (o) { | |
Object.freeze(o.prototype); | |
}); | |
// if in browser, freeze: document, XMLHttpRequest, alert, prompt as wel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment