Javascript 在不兼容的接收器上调用了方法RegExp.prototype.exec
最近,我在使用Javascript 在不兼容的接收器上调用了方法RegExp.prototype.exec,javascript,Javascript,最近,我在使用RegExp.prototype时遇到了一个问题。正常情况下,RegExp.prototype是一个空正则表达式,但是,我尝试在控制台中使用RegExp.prototype.test(“”),这将是错误的。为什么会显示错误 console.log(RegExp.prototype.test.toString()); //RegExp.prototype.test是本机函数 //如果要调用此函数,应新建一个Regexp console.log(新的RegExp(/^$/).test
RegExp.prototype
时遇到了一个问题。正常情况下,RegExp.prototype
是一个空正则表达式,但是,我尝试在控制台中使用RegExp.prototype.test(“”)
,这将是错误的。为什么会显示错误
console.log(RegExp.prototype.test.toString());
//RegExp.prototype.test是本机函数
//如果要调用此函数,应新建一个Regexp
console.log(新的RegExp(/^$/).test(“”))代码>我知道我可以创建新的RegExp。但是为什么Array.prototype.map(function(){})不会出错。所以我对RegExp.prototype感到困扰