The subString() function returns a string that is a specified part of
the value in the string parameter.
Syntax
n = String.subString(string, start, length)
Part
Description
n
The new string returned from the function
string
A string
start
The starting point
length
Specifies the length of the new string
Example
var a = String.subString("world",2,2);
var b = String.subString("world",0,5);
var c = String.subString("world",-2,3);
var d = String.subString("world",2,10);
var e = String.subString("world",10,10);
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.