字符串indexof方法
givesthepositionofthefirstoccurrenceofthestringpassedasparameterinthecurrentstring.returns-1 ifthestringisnotfound。
给出字符串在作为参数传递的当前字符串中第一个出现的位置。 如果找不到字符串,则返回-1。
' JavaScript '.index of ' script '/4 ' JavaScript '.index of ' JavaScript ' )//0' JavaScript '.index of ' avascript '
可以传递第二个参数来设置起点。
' a nice string'.indexOf('nice '!==-1//true ' anice string '.index of (' nice ',3 )!==-1//false ' anice string '.index of (' nice ',2 )!==-1 //true为:3359 flavio copes.com/JavaScript-string-index of /
字符串indexof方法