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

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
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