I would like to know if there is a native javascript code that does the same thing as this:
function f(array,value){ var n = 0; for(i = 0; i < arr
You could use reduce to get there:
Working example
var a = [1,2,3,1,2,3,4]; var map = a.reduce(function(obj, b) { obj[b] = ++obj[b] || 1; return obj; }, {});