# [str.substr](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)
>**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible. Be aware that this feature may cease to work at any time.
==Extracts a part of a string==
___
### Return Value:
`string` (A new string containing the specified part of the given string.)
---
## Description
The **`substr()`** method returns a portion of the string, starting at the specified index and extending for a given number of characters afterwards.
## Examples
```js
const str = 'Mozilla';
str.substr(1, 2); //➞ "oz"
str.substr(2); //➞ "zilla"
```
## Syntax
```js
substr(start)
substr(start, length)
```
### Parameters
`start`
The index of the first character to include in the returned substring.
`length`
Optional. The number of characters to extract.
___
## Notes
`substr()` extracts `length` characters from a `str`, counting from the `start` index.
- If `start` is a non-negative number, the index starts counting from the start of the string. Its value is capped at `str.length - 1`.
- If `start` is a negative number, the index starts counting from the end of the string. Its value is capped at `-str.length`.
- Note: In Microsoft JScript, negative values of the `start` argument are not considered to refer to the end of the string.
- If `length` is omitted, `substr()` extracts characters to the end of the string.
- If `length` is `undefined`, `substr()` extracts characters to the end of the string.
- If `length` is a negative number, it is treated as `0`.
- For both `start` and `length`, `NaN` is treated as `0`.