Path: csiph.com!aioe.org!news.mb-net.net!open-news-network.org!.POSTED.25.224.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Trying to create array of object literals Supersedes: <1699253.tdWV9SEqCh@PointedEars.de> Date: Thu, 19 Apr 2018 03:25:41 +0200 Organization: PointedEars Software (PES) Lines: 70 Message-ID: <1962854.irdbgypaU6@PointedEars.de> References: <2ea2803e-c39d-40e0-b8ed-136c3dc9b4e0@googlegroups.com> <3364120.8dbtfUO1ph@PointedEars.de> <4mv0ddt3bre9bbiofnvabnbamlp9jfj072@4ax.com> <15901681.8V3EAehsKz@PointedEars.de> <3dd0b784-9634-4047-b79b-a171d1e1d099@googlegroups.com> <6c46125d-480d-43af-86db-03bc5200c0bf@googlegroups.com> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit Injection-Info: gwaiyur.mb-net.net; posting-host="25.224.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch:178.197.224.25"; logging-data="8298"; mail-complaints-to="abuse@open-news-network.org" User-Agent: KNode/4.14.2 Cancel-Key: sha1:M25if26c2hpM31BrdzyxLYL5dAo= X-User-ID: U2FsdGVkX19DieZ2KJSNakXEzJjD5xmgtWn1rPbrDeg2UC9zoEYazw== X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. http://www.purl.org/stefan_ram/pub/zuweisungswirkung_javascript > > . That section contains a simplified analysis of the > mechanics of assignment to a global name in JavaScript > using JavaScript's concept of a reference (simplified). [The referred article is in German, which is my native language.] Unfortunately unsurprisingly, that article is *factually* *wrong* in many ways. Indeed, is is that strewn with misconceptions using ad-hoc invented fantasy terminology (such as „globale Einträge“ “global entries” and „Echte Eintragsausdrücke“ “true entry-expressions”) that it would be faster to say what is remotely right in it than what is wrong. It is a complete waste of time to read it, except maybe as yet another example of . For example, (a = 3 + 4) - 2 === 5 _not_ because a === 7 would be the "effect" („Wirkung“) of the assignment as the author believes and wants us to believe, but because the *evaluation result* of the *right-hand* side of an assignment operation is its evaluation *result* (see ES 2017, § 12.15.4 [1]; note that it says “Return *rval*”, and has *always* said something to that effect). The right-hand side here is the expression “3 + 4” whose evaluation result is “7”. So *that* is the result of the assignment expression. The entire expression is evaluated as follows: 1. (a = (3 + 4)) - 2 === 5 2. (a = 7) - 2 === 5 3. 7 - 2 === 5 4. 5 === 5 5. true And _not_: 1. (a = (3 + 4)) - 2 === 5 2. (a = 7) - 2 === 5 3. a - 2 === 5 4. 7 - 2 === 5 5. 5 === 5 6. true As I have explained before (here and in de.comp.lang.javascript), this difference may be subtle, but it is important. For example: /* Afterwards, “o” refers to an object with a read-only “a” property */ var o = Object.create(null, {a: {value: 42}}); /* in non-strict mode */ /* true */ console.log((o.a = 3 + 4) - 2 === 5); /* false; contrary to what one might intuitively expect */ console.log((o.a = 3 + 4) - 2 === 40); BTW, this behavior is true of other programming languages as well. (Why that is so, I actually do not know.) [1] -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.