var a = [2, 2,3,3,3,4];
var res = {};
a.forEach(function(e){
res[e] = 1 + ~~res[e];
})
console.log(res);
HTTP/1.1 200 OK
Date: Tue, 13 Jan 2015 15:08:32 GMT
Content-Type: image/jpeg
Content-Length: 45059
Connection: keep-alive
Keep-Alive: timeout=30
Server: Apache/2
X-Powered-By: PHP/5.2.17
Pragma: no-cache
Content-transfer-encoding: binary
Content-Disposition: filename="20150113100832.jpg"
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private
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 */