Home >Web Front-end >JS Tutorial >Two methods of intercepting strings with js and detailed explanation of their differences_javascript skills

Two methods of intercepting strings with js and detailed explanation of their differences_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:17:26836browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn