Home > Web Front-end > JS Tutorial > JS implementation code to remove the first character and the last character_javascript skills

JS implementation code to remove the first character and the last character_javascript skills

WBOY
Release: 2016-05-16 16:59:01
Original
1183 people have browsed it

There is a string "[lightinthebox]", but I just need lightinthebox, just not "[]". How to remove it quickly and effectively.
stringObject.substring(start,stop) //The start and end strings are intercepted.
stringObject.substr(start,length) //The start and string length are intercepted.
Consider these and connect methods.
stringObject.substr(1).substring(-1,0) //It’s feasible.
Here’s an interception time. Nowadays, there are people who want to change the one digit into two digits. For example, 9 is displayed as 09 to facilitate format alignment.
In many places, it is judged whether the number is less than 10 to determine whether to add 0
If we use a string, there is no need to judge, just add one digit and intercept the last two digits, 01, 010, 011 It becomes 01 10 011

Related labels:
js
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