I want to count the number of occurrences of each character in a given string using JavaScript.
For example:
var str = "I want to count the number of occurrences of each char in this string";
Output should be:
h = 4;
e = 4; // and so on
I tried searching Google, but didn't find any answer. I want to achieve something like this; order doesn't matter.