JavaScript String substring() method

The JavaScript string substring() method retrieves the part of the given string on the basis of the specified index. The original string will not be modified. It is similar to slice, the only difference is that it does not support the negative index.

Note: It returns the complete string if we do not pass any parameter in the method.


string.substring(start_index, end_index) 

start_index: It represents the position of the string from where the string retrieves starts.
end_index: It represents the position up to which the string is retrieved.

Sub string.


<!DOCTYPE html>
var a ="HELLO WORLD!";