Knowledge Walls
Laya
Hyderabad, Andhra Pradesh, India
String.prototype.search() Method in String Class of Javascript Syntax with Examples
1417 Views
Usage 
search() function is used to find the position of string in the main string or sentence.

Note:
This function is case sensitive.To omit case sensitive can follow some syntax.
Syntax
string.search("searchString")
Example
var userName = "cristiano ronaldo";

//if string present
var char1 = userName.search("ronaldo");
document.write("string position is "+char1+" .");

//if string not present
var char2 = userName.search("Ronaldo");
document.write("string position is "+char2+".");
Output 
string position is 10.
string position is -1.
Best Lessons of "Javascript Syntax with Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details