Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Merge indexes.. Date: Wed, 20 May 2015 15:32:47 +0200 Organization: PointedEars Software (PES) Lines: 39 Message-ID: <3972519.ny49QEeFJO@PointedEars.de> References: <143762f6-417f-4f3f-82d5-272939e581d9@googlegroups.com> <87h9r7o7gw.fsf@bsb.me.uk> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1432128928 10393 eJwNyckBwDAIA7CVaMEmjFOu/UdI9RWUD8uNoGGxLlmYhswYIF4nIX9+iOmW0HiRh5pYmqVeGEsQqw== (20 May 2015 13:35:28 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Wed, 20 May 2015 13:35:28 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwYEBgDAIA7CXGKytnCMI/59gguBh6xK8WOzCRbPpUy5N3O6emnUDfCYxalgxvgodS6TIyEQ8/un1H1JuFOA= Cancel-Lock: sha1:82z9BXZ8WeeYd3Y7jVGQz2kGHQ0= X-NNTP-Posting-Host: eJwNyrEBwDAIA7CXSmNsOIc08P8JzaJJvmj8BDrh41PSzoCFYdjNtL2Aky9STsW9T9fVo+eofgcKEJ0= Xref: csiph.com comp.lang.javascript:27776 John Harris wrote: > […] Ben Bacarisse […] wrote: >> jonas.thornvall@gmail.com writes: >>> >> >>Don't make you code worse by adding yet more function that communicate >>via globals. This operation is a self-contained function of the array. >>Pass the array as a parameter and return the result from the function. > > Even better, pass the base, x, as a parameter as well. And for bases from 2 to 36, just return parseInt(a.join(""), base), with both “a” and “base” being formal parameters of merge(). No need to reinvent Wheel 0.1: Finally, make merge() the valueOf() method of your own object type, so that “a” and maybe even “base” can be replaced by references to properties of the instance. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.