Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Remove leading zeros in index of array Date: Tue, 24 Mar 2015 20:47:47 +0100 Organization: PointedEars Software (PES) Lines: 29 Message-ID: <2204699.Ha36KrdQoR@PointedEars.de> References: <2c9d128f-2237-4484-bbbe-2020864ec72a@googlegroups.com> <1518239.EFQcgAjVos@PointedEars.de> <75e22$5511bec1$6def49d7$5093@nntpswitch.blueworldhosting.com> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: solani.org 1427226567 26416 eJwNx8EBwCAIA8CVwJJIx6EB9x/B3u/w0KkdBAMH5xvr9bajso1/qU5NLsseyTe7NKg5k5HkBT1AEl4= (24 Mar 2015 19:49:27 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 24 Mar 2015 19:49:27 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwNxsERACEIBLCWDmFZLAc56L8EnckjUBcvmsMNg2GiJLrzf2IOJyxaU3e/yLemdoxuI1hcjWCWeUlZYM66dKsV6w== Cancel-Lock: sha1:RpYGXXGQhMKv+GDZp3sOPv5DW0E= X-NNTP-Posting-Host: eJwNwocRwDAIBLCVQnnKOMH49x8hOQkWEic9EA7+cNmlT6Id3WU5qm/sTqdYkXOWLn5Ljcn6AAjLEM0= Xref: csiph.com comp.lang.javascript:27127 Cezary Tomczyk wrote: > On 2015-03-24 20:21, Thomas 'PointedEars' Lahn wrote: >> Cezary Tomczyk wrote: >>> bin = bin.filter(function(element){ >>> if (element) { >>> return element; >>> } >>> return false; >>> }); >> >> bin = bin.filter(function (e) { return e; }); > > Your code is shorter then mine. However, I think it's just less readable > in my opinion. Wait till ES 6 (or use Node.js which already supports this): bin = bin.filter(e => e); ;-) -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.