Home > Article > Web Front-end > Two methods of intercepting strings with js and detailed explanation of their differences_javascript skills
var long2="1988-0w-07";
alert(long2.substring(0,4) "------" long2.substring(5,6)); 1988------0
alert(long2.substr(0,4) "------" long2.substr(5,2)); 1988-----0w
substring When intercepting, the coordinates include the front and do not include the back
substr intercepts the coordinate position of the parameter in front of the string, followed by the length of the intercepted string