Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: function to get frequencies of a char array Date: Mon, 26 Jan 2015 13:22:04 +0100 Organization: solani.org Lines: 29 Message-ID: References: <26839541.MRbOrngyXZ@PointedEars.de> <87twzgl0aq.fsf@bsb.me.uk> <2697158.aGRKFDBAEn@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1422274922 6977 eJwFwYEBwCAIA7CXQGjVc1yB/09YgqBTOwkmBmMLgtg8PnFdjZeD+8VkV0n5KqWjZQ7zPT8kihGK (26 Jan 2015 12:22:02 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Mon, 26 Jan 2015 12:22:02 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 X-User-ID: eJwFwYEBwCAIA7CXhtCC59gJ/59gAqfxzyAYGIzmsLx3GHDv7gr5iJk9q8wLX7UdPyZXaekBIboROA== In-Reply-To: Cancel-Lock: sha1:nU/EthTQipqKYDGabkxLYUMbd0w= X-NNTP-Posting-Host: eJwNysEBgDAIA8CVSENA1wHK/iPovU8MRKeHwrVazuY5JWIgNBbBzsql7V9w33LrJ2kaGu4HDigQXg== Xref: csiph.com comp.lang.javascript:26702 Evertjan. wrote: > "Christoph M. Becker" wrote on 24 jan 2015 in > comp.lang.javascript: > >> Evertjan. wrote: >> >>> if (e) counts[e] = (counts[e]|0) + 1; >> >> That has slightly different semantics, which probably won't matter in >> practise, though. Nonetheless I would prefer the following (if I'd use >> a shortcut at all): >> >> if (e) counts[e] = (counts[e] || 0) + 1; > > Indeed, > but if count[] is either undefined or numeric, > as in this case, it does not matter. The semantic difference I was referring to is the internal call of ToInt32()[1]. Compare: 1e32 | 0 // => 0 1e32 || 0 // => 1e+32 [1] -- Christoph M. Becker