Home > Web Front-end > JS Tutorial > Explanation of the difference between substring and substr functions in JS_javascript skills

Explanation of the difference between substring and substr functions in JS_javascript skills

WBOY
Release: 2016-05-16 17:34:23
Original
883 people have browsed it

1. Function declaration in JS: stringObject.substring(start,stop)
start is the starting position of the original string retrieval, stop is the ending position of the retrieval, and the returned result does not include the character pointed by stop.
For example : "hamburger".substring(4,8) returns "urge"

2. substr(start,length)
For example: when the value of DETAIL_TYPE is 1111053, substr(DETAIL_TYPE,1,6) = 111105
Take six characters starting from the first digit of DETAIL_TYPE.

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