Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: Overflow, integers and strings Date: Fri, 01 May 2015 23:37:20 +0200 Organization: solani.org Lines: 23 Message-ID: References: <09495c64-e320-46ca-a6d9-b9f0427c7efd@googlegroups.com> <66061bf2-9092-42a5-918e-5a039a53db20@googlegroups.com> <6ca07e69-1694-49c1-93eb-748c44d8ab68@googlegroups.com> <871tj08vrb.fsf@bsb.me.uk> <1997740.h7VUlrh2Em@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: solani.org 1430516228 13450 eJwFwYEBgDAIA7CXhqUFzlEY/59gQsjU4aKcyy1oLpLvDfUXkS63BAars48Xt4fHjBidrh8MqRBU (1 May 2015 21:37:08 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Fri, 1 May 2015 21:37:08 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 X-User-ID: eJwNx0kBwDAIBEBL3BvkEAj+JbTzG9fgaFh4mK8vubyDqZTBkF3cdSXN3gwuYSjZ9Dt/Rwv9ARVsEQg= In-Reply-To: <1997740.h7VUlrh2Em@PointedEars.de> Cancel-Lock: sha1:jTs0Bzk+ZBtwUt74bFfhEoNPuNs= X-NNTP-Posting-Host: eJwFwQERADEIAzBL5WjZI+eB4V/CEnlY9GEoqNX+H3jPnO6Vlw8z03NxkSsFOFQZWGASbQ8ZwhB0 Xref: csiph.com comp.lang.javascript:27467 Thomas 'PointedEars' Lahn wrote: > Christoph M. Becker wrote: > >> function arraySwap(x,y) { >> var tempArrName = this[y]; >> this[y] = this[x]; >> this[x] = tempArrName; >> } > > Also, “this” is undefined in arraySwap() if that function is called in > strict mode. Yes, indeed. strict mode prevents such dangerous constructs where the global object would be (inadvertently?) modified. It seems to me that a generally correct arraySwap() could be written by interchanging the array *elemtents*, but I'd rather avoid such a function at all. -- Christoph M. Becker