Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Overflow, integers and strings Date: Fri, 01 May 2015 11:08:03 +0100 Organization: A noiseless patient Spider Lines: 33 Message-ID: <87vbgc7gqk.fsf@bsb.me.uk> References: <09495c64-e320-46ca-a6d9-b9f0427c7efd@googlegroups.com> <66061bf2-9092-42a5-918e-5a039a53db20@googlegroups.com> <6ca07e69-1694-49c1-93eb-748c44d8ab68@googlegroups.com> <0b64da34-8f3d-48f6-b522-6dccc2facc94@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="8785"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zmd3F/KLsWsEVeOrH9iJ1Z3CwieoNk3Q=" Cancel-Lock: sha1:0l+sUkJ7LT/sdg5eI7OTQTPLy9Y= sha1:uWpQ/03xHSrwmFLEaEd0To1vZE0= X-BSB-Auth: 1.231fb429583579741472.20150501110803BST.87vbgc7gqk.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:27449 jonas.thornvall@gmail.com writes: > // Compare numerical size of two "reversed"arrays an their index > // If A < B returns true otherwise false > > function arrCompare(A, B) > { > AA=A.length; > BB=B.length; A few people have pointed out that using global names like this is a bad idea. Typing "var" is not very much effort so I wonder why you are still doing this? Do you not believe that it's a bad idea? > function naiveSub(base, subOne, subTwo) > { > prepSubt(subOne,subTwo); > result=[]; > for (i = 0; i < bigArr; i ++ ) Using globals like this is even worse because the reader has to go and hunt down where and to what value bigArr was set. You should write functions that a self-contained and do one simple task each. By the way, mixing up the string conversion and the subtraction is also a bad idea. Once you have a number in your internal array format, there is no need to keep calling parseInt on the elements before every subtraction. -- Ben.