JavaScript provides two similar-looking String manipulation functions, substr and substring, though both are used to get a substring from a String, there is a subtle difference between substring and substr method in JavaScript. If you look at their signature, both substr(to, length) and substring(to, from) both take two parameters, but substr takes the length of the substring to be returned, while substring takes end index (excluding) for substring. This main difference will be more clear when we will see a couple of examples of using substr and substring in JavaScript code.
Difference between SubStr vs SubString function in JavaScript - Tutorial Example
July 21, 2022
0