var a = [2, 2,3,3,3,4];
var res = {};
a.forEach(function(e){
res[e] = 1 + ~~res[e];
})
console.log(res);
Uncaught TypeError: Cannot set property 'module' of undefined
function Increment(){
this.v = 0;
}
Increment.prototype.toString = function(){
return ++this.v;
}
var increment = new Increment();
alert(increment); /* 1 */
alert(increment); /* 2 */
alert(increment + increment); /* 7 */