0

Why javascript indexOf method always return 0 for empty string. If i used any string indexOf("") always returns zero. Any reason for this. Explain the reason briefley.

var str="jquery";
var index=str.indexOf("") \\ Always returns zero for any string.

Thanks in advance.

2
  • because it will find empty string at the very starting of the search string so everytime it will return index 0 Commented Feb 24, 2015 at 9:51
  • stackoverflow.com/questions/1744310/… Commented Feb 24, 2015 at 9:52

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.