以下是如何避免console.log
具体破坏:
var console = window.console || {"log": function(){} };
通常,如果您想避免使用默认 (||) 或三元 (?:) 运算符,请使用调度表:
/* Check for IE Mutation Event */
var browser = "onpropertychange" in document;
/* Map boolean values to variables */
var detect = { "true": ie_param, "false": w3_param };
/* Map string templates with escaped quotes to variables */
var w3_param = [".addEventListener","\u0022DOMAttrModified\u0022",",false"];
var ie_param = [".attachEvent","\u0022onpropertychange\u0022",""];
/* Shadow array indices with key/value pairs */
var api = {"event":0,"attribute":1,"state":2};
/* Generate DOM lookup based on boolean value and matching string template */
var result = "document.getElementsByTagName(\u0022body\u0022)[0]".concat(detect[browser][api.event], "(", detect[browser][api.attribute], ",alert", detect[browser][api.state], ")");
/* Execute generated code */
var lazy = Function(result);
可选地指向元素数组的对象。该对象始终具有相同数量的键/值对,并且每个数组元素始终具有相同的大小。因此,可以按名称或按值访问数组索引。
参考