I have an array of fruits which has following elements
var fruits = ['Mango','Orange', 'Banana', 'Mango', 'Grapes', 'Orange', 'Apple', 'Apple', 'Banana', 'Mango']
And I want generate an output of object array which can be
result = [{fruit : 'Mango', Count : 3}, {fruit : 'Orange', Count : 2}, {fruit : 'Banana', Count : 2},{fruit : 'Grapes', Count : 1}, {fruit : 'Apple', Count : 2}]
How can I achieve the same?