indexOf()和search()有什么区别? [英] What is the difference between indexOf() and search()?
本文介绍了indexOf()和search()有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于JavaScript来说还很陌生,我无法确定何时使用它们.
Being fairly new to JavaScript, I'm unable to discern when to use each of these.
有人可以帮我澄清一下吗?
Can anyone help clarify this for me?
推荐答案
如果需要正则表达式,请使用search()
.否则,indexOf()
会更快.
If you require a regular expression, use search()
. Otherwise, indexOf()
is going to be faster.
这篇关于indexOf()和search()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文