function get_occurrence(varS,string){//Find All Occurrences
c=(string.split(varS).length - 1);
return c;
}
string="Hi, 1,2,3";
console.log(get_occurrence(",",string));
Use get_occurrence(varS,string) to find occurrence of both characters and string in a String.