I need to count the number of occurrences of a character in a string.
For example, suppose my string contains:
var mainStr = \"str1,str2,str3,str4\";
Add this function to sting prototype :
String.prototype.count=function(c) { var result = 0, i = 0; for(i;i
usage:
console.log("strings".count("s")); //2