|
| |
indexOf to get location of a string |
We can find out the location of a particular string inside the main string by using indexOf function. This is some what opposite of the charAt function which returns the char once a location is given. By using indexOf function we can find out the location and this function returns a number. The first character of the main string is considered as 0 location. Here is an example of indexOf function.
<script type="text/javascript">
var my_str="Welcome to www.plus2net.com"
document.write(my_str.indexOf("plus"))
</script>
The above code will return 15
| |
| Subscribe |
|
Submit your email address and receive
article and product notifications. Your email is safe with us.
|
|
|
|