- 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:-
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>search()</h1>
- <input type="button" onclick="strfun();" value="Get Answer">
- <script>
- function strfun()
- {
- var str = "Place of Marthandam";
- alert(str.search("of")); //return 6
- }
- </script>
- </body>
- </html>
What is a search JavaScript:- Geniusofstudent
Reviewed by Network security
on
June 30, 2019
Rating:
No comments: