The slice() method is used to extract a part of a string. It will return extracted part in a new string and does not have any effect on the original string. A negative number will start selecting from the end of the string.
Its syntax is:- string.slice(start, end)
Its return is:- extracted part of string
|start||Required. The start position.|
|end||Optional. The end position.|