Standard built-ins
String.prototype.slice()
Extracts the half-open range; negative indices count from the end. A reversed normalized range returns empty.
Formal Syntax & Structure
javascript syntaxjavascript
text.slice(start, [end])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| start | Number | Starting code-unit offset. |
| end | Number | Exclusive end offset; defaults to length. |
Return Value
String
Extracted code-unit sequence.
Working Example
Example Snippetjavascript
console.log("abcdef".slice(-3,-1));