js eliminar la coma final

str = str.replace(/,\s*$/, "");
Borma