Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 17:17:26
Original
812 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!