JavaScript Substr
substr() returns a portion of a string starting at a given index and spanning a given length. It is a legacy method — prefer slice() in new code — but you will still meet it in the wild.
Syntax
str.substr(start, length) Examples
| Input | Arguments | Output |
|---|---|---|
| "hello" | 1, 3 | "ell" |
Gotchas
- substr() is deprecated. Use slice() or substring() instead.
Try it live
Type your input and see Substr transform it instantly.
Want to go further? Chain Substr with other functions in the visual Playground — pipe one output into the next and watch your data transform.