1.slice();
Both Array and String objects are
slice(i,[j]) in Array
i is the index value that starts to be intercepted, the negative number represents the index value calculated from the end, and -1 is the last element
j is the end index value, and by default, all elements from i to end are obtained.
Parameters return:
Returns an array with index value from i to j, the original array does not change
slice(i,[j]) in String
Parameter description:
i is the index value that starts to be intercepted, the negative number represents the index value calculated from the end, and -1 is the last character
j is the end index value, and by default, all characters from i to end are obtained.
2.splice()
A method exists in Array to add/remove items to/from the array and then returns the deleted item. This method changes the original array
splice(index,howmany,item1,itemx)
index : Required. Integer, specify the position where items are added/deleted, and use negative numbers to specify the position from the end of the array.
howmany: Required. Number of items to be deleted. If set to 0, the item will not be deleted.
item1...itemX : Optional. New items added to the array.
Return value Array contains the new array of deleted items, if any.
3.split()
split(separator, howmany) in String
separator: Required. A string or regular expression that splits stringObject from where this parameter specifies.
howmany: Optional. This parameter specifies the maximum length of the returned array. If this parameter is set, the returned substrings will not be more than the array specified by this parameter. If this parameter is not set, the entire string will be split regardless of its length.
Return value
An array of strings. This array is created by splitting the string StringObject into substrings at the boundary specified by the separator. The string of the returned array does not contain the separator itself
However, if separator is a regular expression containing subexpressions, the returned array includes strings matching those subexpressions (but not text matching the entire regular expression)
The opposite effect to jion() function
4.substring()
Substring(start,stop) in String
start: indicates the start position of the substring.
stop: indicates the end result.
Note: The second parameter should be greater than the first parameter. If the first parameter is greater than the second parameter, the substring method will automatically change the position of the two parameters.
5.substr()
In String, substr(start, length);
start: the start position of the substring,
length: length of the substring.
The above is all about this article, I hope you like it.