How to detect multiple same items in an array

hello, first time here… want to ask a question which i have been thinking for quite sometime …

say i have an array be it of any length …

[COLOR=Sienna]var Myarray= new array(“apple”, “pear”, “apple”,“orange”, “apple”,“pear” )

[COLOR=Black]how shld i write a function that will detect and group similar items into each individual unqiue counter,

item “apple” :3
item “pear” : 2
item “orange”:1

also does anyone here have resources(books or website) for problem solving for actionscript… problems like the one on top… ? I really need to learn to improve in different approaches in solving a scripting problem.
[/COLOR][/COLOR]

welcome