But, for a new developer, it creates confusion which one to use.
thought of clearing the minor difference that exists between these two APIs.
Let’s consider an example.
var text = “This world is a great place to live”;
// substring – Start trimming after the 5th character and cut text upto 10th character
console.log( text.substring ( 5 , 10 ) ); // Output: “world”
// substr – Start trimming after the 5th character and cut next 10 characters
console.log( text.substr( 5 , 10 ) ); // Output: “world is a”