ALARMus,
<script>
var array='A,1,A,2,B,3,C,4'.split(',');
function fn(array)
{
var res = [], n = 1, obj = {};
for (var i = 0; i < array.length; i+=2) {
var f = array[i];
if(!obj[f]){
res.push(f, n++ );
obj[f] = true;
}
}
return res
}
document.write(JSON.stringify(fn(array)))
</script>