Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <2069686.qHTUFZlykZ@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Wed, 11 Dec 2013 18:27:26 +0100 User-Agent: KNode/4.11.3 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. column ? Newsgroups: comp.lang.javascript References: <4a645078$0$292$7a628cd7@news.club-internet.fr> <8d349f92-a64b-4837-9f00-cbcc4d07f985@k19g2000yqn.googlegroups.com> <0a06e88a-f13d-4ced-a49a-361556b80643@googlegroups.com> <1536350.F63rdpPjnV@PointedEars.de> MIME-Version: 1.0 Lines: 64 NNTP-Posting-Date: 11 Dec 2013 18:27:30 CET NNTP-Posting-Host: 683da261.newsspool2.arcor-online.net X-Trace: DXC=@eJlkJg66C]U6b:FjPaGjQA9EHlD;3YcR4Fo<]lROoRQ8kF Em 10/12/2013 21:22, Thomas 'PointedEars' Lahn escreveu: >> Denis McMahon wrote: >>> function hide(tid,c,h=true){ >> ^^^^^ >> Syntax error. Default parameters cannot (yet) be defined this way in >> strictly conforming implementations of ECMAScript. You have to >> initialize them if they are not present, for example: >> >> function hide(tid, c, h) >> { >> if (typeof h == "undefined") >> { >> h = true; >> } > > Considering your "strictly conforming implementations of ECMAScript", > it could be just: > > if (h === undefined) { h = true; } Non sequitur. The “undefined” property of the Global Object did not always have the ReadOnly attribute before. You knew fairly well what I meant by “strictly conforming” in that regard, did you not? > or > > h = h || true; Not equivalent; also inefficient, and error-prone. >> /* or */ >> >> if (arguments.length < 3) >> { >> h = true; >> } >> >> The difference between the first and second approach is that with the >> second one there is no false positive if “undefined” is passed for “h”. > > It's not the case, Yes, it is. Passing any value, even the “undefined” value, will increase the value of arguments.length, but passing the “undefined” value cannot be told from not passing *any* (here: third) argument if you use typeof or compare against “undefined” (provided that it has not been overwritten) because formal parameters for which no argument has been passed are initialized with (the built-in) “undefined” implicitly. > but there is a problem with this sort of testing when > an optional argument is passed a value from another source such as a > configuration object, when it might produce undefined. That's why it is > better to test for undefined. Neither test is viable when a parameter object is passed, and nobody but you suggested that it is intended to. You are jumping to conclusions again. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.