![]() ![]() ![]() The following example uses slice() to create a new string. Examples Using slice() to create a new string str.slice(1, 4) extracts the second character through the fourth character (characters indexed 1, 2, and 3).Īs an example, str.slice(2, -1) extracts the third character through the second to last character in the string. Slice() extracts up to but not including endSlice. Changes to the text in one string do not affect the other string. Slice() extracts the text from one string and returns a new string. Return valueĪ new string containing the extracted section of the string. If negative, it is treated as sourceLength + endSlice where sourceLength is the length of the string (for example, if endSlice is -3 it is treated as sourceLength - 3). If omitted, slice() extracts to the end of the string. The zero-based index at which to end extraction. If negative, it is treated as sourceLength + beginSlice where sourceLength is the length of the string (for example, if beginSlice is -3 it is treated as sourceLength - 3). slice(beginSlice ) Parameters beginSlice The zero-based index at which to begin extraction. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |