Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-05-16 17:34:23866browse

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.

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