The difference between substr() method and substring() method in HTML

sunstr() method

Usage: sunstr(start, length)
starts counting from 0, and intercepts a string of length length from start.

Example:

<script>
	var letters="asdfghjkjhgfds";
	console.log(letters.substr(3,6));
</script>

The result is: fghjkh

 

sunstring() method

Usage: sunstring (start, stop)
starts counting from 0, and intercepts the string from start to stop, excluding start.
Code example:

<script>
	var letters="asdfghjkjhgfds";
	console.log(letters.substring(3,6));
</script>

The result is: fgh
 

Guess you like

Origin blog.csdn.net/m0_46383618/article/details/107414169