0
The two metohds, indexOf() , search()are equal ? In java script !!
this methods return same value, accept same argument , then why two different method is use ??
2 ответов
+ 4
indexOf() is an Array object based method, searching in a string as an arrat like object (array of char), while search() is effectively regular expression based...
They are not stricly the same, even if they are equivalent on some context ^^
+ 3
"The search value can be string or a regular expression."
So I suppose search() is designed for regular expressions, while indexOf is not.
Quote from:
https://www.w3schools.com/jsref/jsref_search.asp