Javascript Programming Tips & Tricks





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Code Snippets
 List All
 Add Snippets
 Alerts & Prompts
 Array Methods
 Convertors
 Date
 Date & Time
 Error Handling
 Form Validation
 Image Effects
 Mathematical Functions
 Mouse Tricks
 Randomizing
 Redirection
 String Functions
 Text Effects
 Window / User Info
 

strpos - Javascript

Snippets  Javascript  Strpos


Snippet On
strpos in javascript




Code
  
Rate this page :
  [ 0 votes]

Find the occurrence of a string using strpos in javascript.

function strpos (haystack, needle, offset) {
var i = (haystack '').indexOf(needle, (offset || 0));
return i === -1 ? false : i;
}

call the function as,

var res='scripts,tutorials,tools';
strpos(res, ',');

result will be,
2




Other Links

web hosting