将字符串分割成数组,数组每一项包含step个字符。最后一项的字符个数可以小于step。
Example
str.chop('whitespace') // ['whitespace']
str.chop('whitespace', 2) // ['wh', 'it', 'es', 'pa', 'ce']
str.chop('whitespace', 3) // ['whi', 'tes', 'pac', 'e']
str.chop(12345, 1) // ['1', '2', '3', '4', '5']
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
str |
String | 需要分割的字符串 | ||
step |
String |
<optional> |
str.length
|
数组每一项的字符个数 |
Returns:
分割后的数组
- Type
- Array