“ String.prototype.search”可以有一个字符串参数吗?

时间:2019-06-24 11:33:23

标签: javascript

The MDN documentation说,“ String.prototype.search”的单个参数是一个正则表达式对象RegExp。但是看来我也可以在我的Chrome 75中给它string供电;而且有效。这是Chrome特定的行为,还是我可以依靠的标准

console.log("ABCDEF".search(/BCD/)); // 1 // Good
console.log("ABCDEF".search("BCD")); // 1 // Good?

0 个答案:

没有答案