String.prototype.replaceLastOccurrence = function(search, replace) {
return this.replace(new RegExp(search + "([^" + search + "]*)$"), replace + "$1");
}
let str = 'c c++, nodejs, python, php';
str = str.replaceLastOccurrence(",", "");
console.log(str);
/*
run:
c c++, nodejs, python php
*/