JavaScript | javascript substring indexof
ThisJavaScripttutorialexplainshowtousethestringmethodcalledindexOf()withsyntaxandexamples.DescriptionInJavaScript,indexOf()isastringmethodthatisusedtofindthelocationofasubstringinastring.BecausetheindexOf()methodisamethodoftheStringobject,itmustbeinvokedthroughaparticularinstanceoftheStringclass.SyntaxInJavaScript,thesyntaxfortheindexOf()methodis:string.indexOf(substring[,start_position]);ParametersorArgumentssubstringItisthesubstringthatyouwanttofindwithinstring.start_positionOptional.Itist...
This JavaScript tutorial explains how to use the string method called indexOf() with syntax and examples.
DescriptionIn JavaScript, indexOf() is a string method that is used to find the location of a substring in a string. Because the indexOf() method is a method of the String object, it must be invoked through a particular instance of the String class.
SyntaxIn JavaScript, the syntax for the indexOf() method is:
string.indexOf(substring [, start_position]); Parameters or Arguments substring It is the substring that you want to find within string. start_position Optional. It is the position in string where the search will start. The first position in string is 0. If this parameter is not provided, the search will start at the beginning of string and the full string will be searched. ReturnsThe indexOf() method returns the position of the first occurrence of substring in string. The first position in the string is...