What is a search JavaScript:- Geniusofstudent

  • The search() method searches a string for a specified value, and returns the position of the match.
  • The search value can be string or a regular expression.
  • This method returns -1 if no match is found.

Code:-

  1. <!DOCTYPE html> 
  2. <html> 
  3.  
  4. <head> 
  5.  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  6. </head> 
  7.  
  8. <body> 
  9.  
  10.  <h1>search()</h1> 
  11.  
  12.  <input type="button" onclick="strfun();" value="Get Answer"> 
  13.  
  14.  <script> 
  15.   function strfun() 
  16.   { 
  17.    var str = "Place of Marthandam"; 
  18.    alert(str.search("of")); //return 6 
  19.   } 
  20.  </script> 
  21.  
  22. </body> 
  23.  
  24. </html>
What is a search JavaScript:- Geniusofstudent What is a search JavaScript:- Geniusofstudent Reviewed by Network security on June 30, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.