Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.42!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1550675.qVoOGUtdWV@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Thu, 17 Nov 2011 23:54:08 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit Subject: Re: Difference between findPos("divThis") and findPos(divThis) Newsgroups: comp.lang.javascript References: <4775241.ypaU67uLZW@PointedEars.de> <2394720.ArG6xLiZAS@PointedEars.de> <4ec07ef1$0$28711$a8266bb1@newsreader.readnews.com> <4ec11fb1$0$28605$a8266bb1@newsreader.readnews.com> <4ec15e82$0$28617$a8266bb1@newsreader.readnews.com> <9iles3FnvhU1@mid.individual.net> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 48 NNTP-Posting-Date: 17 Nov 2011 23:54:08 CET NNTP-Posting-Host: a8c9ab68.newsspool3.arcor-online.net X-Trace: DXC=QU;CCV_6dA=]E=H1Q9`787McF=Q^Z^V384Fo<]lROoR18kFeCcZnA96a>1 X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:8397 Frobernik wrote: > You could squeeze more out of the available space and avoid the use of a > var completely > > Using the original example > > function findPos(obj) { > var w = obj.offsetWidth; > var h = obj.offsetHeight; > } > findPos(divThis) > > becomes :- > > function findPos(obj, w, h) { > w = obj.offsetWidth; > h = obj.offsetHeight; > } > findPos(divThis) > > another style/variant could be > > function findPos(obj, name, colour, b, c) { > name = obj.name; > colour = obj.colour; > b = 17; > c = [{s:'monkey', x:'male', a:3}, {s:'elephant',x:'female',a:7}]; > } > findPos({name:'df', colour:'green'}) (Jorge, is it you?) We have been over this. Declaring arguments instead of local variables may be great for code golfing (140 characters maximum), but it is a Really Bad Idea for all other code. To begin with, by looking at the code you cannot tell whether you are modifying an argument or not. Editors and linters which can differentiate between arguments and local variables could not tell as well. PointedEars -- > If you get a bunch of authors […] that state the same "best practices" > in any programming language, then you can bet who is wrong or right... Not with javascript. Nonsense propagates like wildfire in this field. -- Richard Cornford, comp.lang.javascript, 2011-11-14