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: Fri, 23 Jan 2015 17:09:10 +0100 Organization: PointedEars Software (PES) Lines: 25 Message-ID: <2355442.d5ZcC854NQ@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1422029390 31863 eJwNysEBwCAIA8CVpECUcQw2+4+g9750GHoGEpFK1Sl5k/O49QoUP+8xNDaS6n+9DlbJNt+1Cyf9EW4= (23 Jan 2015 16:09:50 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Fri, 23 Jan 2015 16:09:50 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwNysEBwCAIA8CVRJKA4yDq/iO09z66TB0QBT6+qWYvmeE4aWdnYGVvaI97ta4i/zwmI7J6lON5lddEVlAfL+sUfw== Cancel-Lock: sha1:Uwc6S5TO0oOWWg+e1HVyZ7pkW28= X-NNTP-Posting-Host: eJwNysEBwCAIA8CVjJCg44jI/iO09z6aoBsuytls8OZbTzM7DGaaQ9t9gZ59Yv8JzaokQyV9DcwQgw== Xref: csiph.com comp.lang.javascript:26671 Denis McMahon wrote: > On Thu, 22 Jan 2015 14:43:18 -0800, JRough wrote: >> function frequencies(){ >> var arr = ['a', 'b', 'j','c', 'd', 'j', 'j', 'j']; >> var key, value; >> for(i=0; i< arr.length; i++){ > > i wasn't defined with a var statement. A “var” statement constitutes a *declaration*, with an optional initialization; not a definition. > Not a critical error, Wrong. Not declaring an identifier and then assigning to it causes it to be looked up in the entire scope chain in non-strict mode (which can lead to a runtime error in some environments), and a ReferenceError exception to be thrown in strict mode. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.