1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Intercept the string one substring</title>6 </Head>7 <Body>8 <Script>9 /*the substring () method is used to extract the character of a string intermediary between two specified subscripts. */Ten /*stringobject.substring (start,stop)*/ One /* A parameter Description - start required. A nonnegative integer that specifies the position of the first character of the substring to be extracted in the stringobject. - Stop the Optional. A nonnegative integer that is 1 more than the last character of the substring to extract in Stringobject. - If this argument is omitted, the returned substring continues until the end of the string. - */ - /* + return value - a new string value that contains a substring of stringobject whose contents are all characters from start to stop-1, with a length of stop minus start. + Description A the substring returned by the substring () method includes the character at start, but does not include the character at the stop. at If the argument start is equal to stop, the method returns an empty string (that is, a string of length 0). If start is larger than stop, the method swaps both parameters before extracting the substring. - */ - /* - Hints and notes - Important: Unlike the slice () and substr () methods, substring () does not accept negative parameters. - */ in - vara="Xcvbnmz"; to varC=a.substring (3,1); + varC1=a.substring (1,5); - varC2=a.substring (1); the /* * if the parameter value is negative, the value is converted to 0; $ */Panax Notoginseng varC3=a.substring (1,-3); - Console.log (c); the Console.log (C1); + Console.log (C2); A Console.log (C3); the </Script> + </Body> - </HTML>
Intercept the string one substring