Home > Web Front-end > JS Tutorial > A simple way to remove the right comma in JS_javascript skills

A simple way to remove the right comma in JS_javascript skills

WBOY
Release: 2016-05-16 17:30:20
Original
1202 people have browsed it

Copy code The code is as follows:

function rtrim(s) {

var lastIndex = s.lastIndexOf(',');
if (lastIndex > -1) {
s = s.substring(0, lastIndex);

}
return s; A 0-based indexed integer indicating the starting position of the substring.
end
Required. A 0-based indexed integer indicating the end of the substring.

Remarks
The substring method will return a string that contains the substring from start to end (excluding end).
lastIndexOf(parameter), if the parameter does not exist, it returns -1
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