What is the use of substring method in JavaScript
This article mainly introduces what is the use of the substring method in JavaScript, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The substring method returns the substring at the specified location in the String object.
StrObj.substring (start,end)
Description:
Start indicates the starting position of the substring, with the index starting at 0.
End indicates the end of the substring, with the index starting at 0.
The substring method uses the smaller of both start and end as the starting point for the substring. If start or end is NaN or negative, replace it with 0.
For example:
012345
Var str = "ABCDEF"
Str.substring (2pr 4); / / or str.substring (4pr 2)
Results: CD
Thank you for reading this article carefully. I hope the article "what is the use of substring in JavaScript" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!