What is the deference between subString() and substr()? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the deference between subString() and substr()?

The substr() method extract the string in a string and the subString() is the same extract string

1st Jan 2020, 5:22 PM
Rohani
Rohani - avatar
2 Answers
0
The difference is in the second argument. The second argument to substring is the index to stop at (but not include), but the second argument to substr is the maximum length to return. https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_substring https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_substr
2nd Jan 2020, 4:48 AM
Shaili Shah
Shaili Shah - avatar