![]() ![]() The following example uses the substring() method and length property to extract the last characters of a particular string. The following example uses substring() to display characters from the string 'Mozilla': var anyString = 'Mozilla' If indexStart is greater than inde圎nd, then the effect of substring() is as if the two arguments were swapped for example, str.substring(1, 0) = str.substring(0, 1). If either argument is greater than stringName.length, it is treated as if it were stringName.length.If either argument is less than 0 or is NaN, it is treated as if it were 0.If inde圎nd is omitted, substring() extracts characters to the end of the string. ![]() If indexStart equals inde圎nd, substring() returns an empty string.Substring() extracts characters from indexStart up to but not including inde圎nd. Return valueĪ new string containing the extracted section of the given string. An integer between 0 and the length of the string, which specifies the offset into the string of the first character not to include in the returned substring. Syntax str.substring( indexStart) Parameters indexStart An integer between 0 and the length of the string, specifying the offset into the string of the first character to include in the returned substring. The substring() method returns a subset of a string between one index and another, or through the end of the string.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |