在我的项目中,我正在解析 JavaScript 代码,尤其是像document.createElement
正则表达式这样的动态函数。但有人建议我把它包document.createElement
起来做钩子。我不明白该怎么做
他们还提供了一个例子:
var f = document.createElement;
document.createElement = function(tagName){
console.log(tagName);
f.apply(document, arguments);
}
此代码正在跟踪document.createElement
我无法理解如何在我的代码中使用它,任何人都可以帮助我