Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Frobernik Newsgroups: comp.lang.javascript Subject: Re: Difference between findPos("divThis") and findPos(divThis) Date: Thu, 17 Nov 2011 22:06:58 +0000 Lines: 55 Message-ID: <9iles3FnvhU1@mid.individual.net> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net q5ftgoU8tGpSUSENFDG4aAnUwVQxH/jlWNd3/QbzF0U4EEdcm9 Cancel-Lock: sha1:0lBZvxywzTNVYJzWZKdRm2HFOU4= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:8394 On 16/11/2011 14:04, Scott Sauyet wrote: > Richard Cornford wrote: >> Scott Sauyet wrote: >>> Denis McMahon wrote: >>>> Minimisation is good, but the following: >> >>>> var a = "df"; >>>> var b = 17; >> >>> Another contender is this: >> >>> var a = "df", >>> b = 17; >> >> ^ oops! >> >>> c = [{s:'monkey',x:'male',a:3},{s:'elephant',x:'female',a:7}, >> >>> ... . Richard's argument against the comma are reasonable, ... >> ;-) > > Perhaps I should have said "are eminently reasonable"." :-) > > -- Scott 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'}) Frobernik