strpos - Javascript

strpos in javascript

Snippet 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

Tags