Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: function to get frequencies of a char array Date: Tue, 27 Jan 2015 22:15:55 +0100 Organization: PointedEars Software (PES) Lines: 29 Message-ID: <2193243.aBhPuaqYS3@PointedEars.de> References: <26839541.MRbOrngyXZ@PointedEars.de> <87twzgl0aq.fsf@bsb.me.uk> <2697158.aGRKFDBAEn@PointedEars.de> <10619254.HIfIgzSeSj@PointedEars.de> <4289181.7vYxkYjVZ3@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1422393396 28954 eJwFwQERADEIAzBLK9Cyl8PB8C/hE7qgzhAVXK4K/XS9zC/ZVicBDXqD49VQ2NZapH0j8gcSHxCV (27 Jan 2015 21:16:36 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 27 Jan 2015 21:16:36 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwQkBwDAIA0BLfAlFDrTDv4Tdwam8GQQDi7Ul/ToLbbnq29Kok2zt+sKevPDju2mA+lBFaHNZoXdGfjUKFJQ= Cancel-Lock: sha1:rts45MMNM0srJt25M7l7Tzr7aMk= X-NNTP-Posting-Host: eJwFwYEBwDAEBMCVCP8Yp6L2HyF3MCpvOEHHYrsPheFoPZpXrLc4K/bZEjnT7rAKSUXX/g8N6BCk Xref: csiph.com comp.lang.javascript:26734 Christoph M. Becker wrote: > Thomas 'PointedEars' Lahn wrote: >> Christoph M. Becker wrote: >>> As we were talking about array *indexes*[1], values equal to or beyond >>> 2³² are irrelevant, anyway. >>> >> […] > for (var i = 0, len = a.length; i < len; ++i) > { > /* NOTE: hasOwnProperty() may be required */ > var e = a[i]; > if (e) { counts[e] ? ++counts[e] : (counts[e] = 1); } > } > > Indeed, `e` is no array index, but `i` is. Therefore the value of the > properties of `count` is always less than 2³² (even though it could be > greater than or equal to 2³¹). But you can have arrays and array-like objects with up to 2⁵³ elements and iterate over them this way: -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.