Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

difference between indexof and search in javascript

		/* differences between .search() and .indexOf()*/

//If you require regular expression use 
.indexOf()
//otherwise use 
.search()

//other diffrences with example:

//.search() doesn't have starting position
  var text = 'example: this is the example and example'; //bunch of nonsenss
  text.indexOf('example', 9); //9: this is the starting position and its optional
  text.search('example')
 
PREVIOUS NEXT
Tagged: #difference #indexof #search #javascript
ADD COMMENT
Topic
Name
6+2 =