How to use split method to intercept string in js
This article mainly explains "how to intercept strings with split method in js". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to intercept strings with the split method in js".
1. Split () method
Is a string method that can cut strings into arrays.
2. Grammar
StringObject.split (separator,howmany)
3. Parameters
Separator (required): is a string or regular expression that splits the stringObject from the place specified by this parameter.
Howmany (optional): this parameter specifies the length of the returned array.
Note: if howmany is set, no more substrings will be returned than the array specified by this parameter. If howmany is not set, the entire string will be split, regardless of its length.
4. Return value
An array of strings.
5. Examples
Example: str= "2018.12"; arr=str.split ("."); / / arr is an array containing "2018" and "12", and arr [0] is 2018 Magi Arr [1] is 12. At this point, I believe you have a deeper understanding of "how to intercept strings with the split method in js". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!