有什么方法可以防止用户覆盖本机功能?
例:
var getRand;
(function(){
'use strict';
getRand = function(){
return Math.random();
}
})();
getRand(); //gives a nice random number
Run Code Online (Sandbox Code Playgroud)
页面加载后,在控制台中覆盖。
Math.random = function (){ return 0 };
getRand(); //gives 0 :(
Run Code Online (Sandbox Code Playgroud)
有什么方法可以防止本机函数被覆盖?也许使用CSP或密封对象...这甚至可能吗?