Why javascript indexOf “empty string” always returning zero [duplicate]

淺唱寂寞╮ 提交于 2020-01-07 04:16:28

问题


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.

来源:https://stackoverflow.com/questions/28692565/why-javascript-indexof-empty-string-always-returning-zero

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!