You cannot get
var data = [14:"A",5:"IMG",2:"SPAN"]
because that is not valid JavaScript. Also, if the count would end up being similar for different tags, you would get duplicate keys. Turn the key/values around, and use JavaScript object:
var reduced = {A: 14, IMG: 6, SPAN: 2};
In Ecmascript 5:
var data = ["A","A","A","IMG","IMG","A","A","IMG","A","A","IMG","A","A","IMG","IMG","A","A","A","A","A","SPAN","SPAN"];
var reduced = data.reduce(function (result, item) {
result[item] = (result.hasOwnProperty(item) ? result[item] : 0) + 1;
return result;
}, {});
console.log(reduced); // Object {A: 14, IMG: 6, SPAN: 2}
jsFiddle here
If you need to support browsers without "reduce", you can find reduce in underscore.js
var reduced = _.reduce(data, function (result, item) {
result[item] = (result.hasOwnProperty(item) ? result[item] : 0) + 1;
return result;
}, {});
jsFiddle with underscore here