Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34871
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Trying to create array of object literals |
| Date | 2018-04-19 03:25 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <1962854.irdbgypaU6@PointedEars.de> (permalink) |
| References | (8 earlier) <6c46125d-480d-43af-86db-03bc5200c0bf@googlegroups.com> <XnsA8C67492593DDeejj99@194.109.6.166> <f388b2d9-a414-48c8-87b5-0029715758e5@googlegroups.com> <agr9dddd5fmufb4msghkn04eg1nonnq1e6@4ax.com> <Reference-20180416212304@ram.dialup.fu-berlin.de> |
Stefan Ram wrote:
> 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
<https://www.crockford.com/javascript/javascript.html>.
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] <http://www.ecma-international.org/ecma-262/8.0/#sec-assignment-operators-runtime-semantics-evaluation>
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Trying to create array of object literals bit-naughty@hotmail.com - 2018-04-12 12:17 -0700
Re: Trying to create array of object literals bit-naughty@hotmail.com - 2018-04-12 12:26 -0700
Re: Trying to create array of object literals Maik Koenig <usenetspam@maikkoenig.de> - 2018-04-12 21:47 +0200
Re: Trying to create array of object literals Julio Di Egidio <julio@diegidio.name> - 2018-04-12 12:49 -0700
Re: Trying to create array of object literals Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-13 10:27 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-13 10:57 +0100
Re: Trying to create array of object literals Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-13 23:38 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-14 11:22 +0100
Re: Trying to create array of object literals Julio Di Egidio <julio@diegidio.name> - 2018-04-14 07:25 -0700
Re: Trying to create array of object literals Julio Di Egidio <julio@diegidio.name> - 2018-04-14 09:09 -0700
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-16 09:43 +0100
Re: Trying to create array of object literals Julio Di Egidio <julio@diegidio.name> - 2018-04-16 02:04 -0700
Re: Trying to create array of object literals "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-16 11:23 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-16 19:32 +0100
Re: Trying to create array of object literals "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-17 23:37 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-18 16:18 +0100
Re: Trying to create array of object literals "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-19 23:08 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-20 10:17 +0100
Re: Trying to create array of object literals "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-20 12:45 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-20 19:08 +0100
Re: Trying to create array of object literals "c.l.js" <trollhunter@curiosity.kills.no> - 2018-04-20 17:04 -0300
Re: Trying to create array of object literals Julio Di Egidio <julio@diegidio.name> - 2018-04-20 13:15 -0700
Is JS a functional programming language? (was: Trying to create array of object literals) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-21 02:35 +0200
Re: Is JS a functional programming language? (was: Trying to create array of object literals) Julio Di Egidio <julio@diegidio.name> - 2018-04-21 01:36 -0700
Re: Is JS a functional programming language? (was: Trying to create array of object literals) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-04-21 11:46 -0700
Re: Is JS a functional programming language? (was: Trying to create array of object literals) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-04-21 11:48 -0700
Re: Is JS a functional programming language? (was: Trying to create array of object literals) Julio Di Egidio <julio@diegidio.name> - 2018-04-21 23:53 -0700
Re: Is JS a functional programming language? (was: Trying to create array of object literals) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-04-22 10:33 -0700
Re: Is JS a functional programming language? (was: Trying to create array of object literals) Julio Di Egidio <julio@diegidio.name> - 2018-04-23 00:27 -0700
Re: Is JS a functional programming language? (was: Trying to create array of object literals) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-04-23 11:50 -0700
Re: Is JS a functional programming language? (was: Trying to create array of object literals) Julio Di Egidio <julio@diegidio.name> - 2018-04-23 12:00 -0700
Re: Is JS a functional programming language? (was: Trying to create array of object literals) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-04-23 15:07 -0700
Re: Is JS a functional programming language? "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-04-24 00:47 +0200
Re: Is JS a functional programming language? Julio Di Egidio <julio@diegidio.name> - 2018-04-23 16:12 -0700
Re: Is JS a functional programming language? "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-04-24 01:30 +0200
Re: Is JS a functional programming language? Julio Di Egidio <julio@diegidio.name> - 2018-04-23 16:45 -0700
Re: Is JS a functional programming language? John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-24 09:54 +0100
Re: Is JS a functional programming language? Tim Streater <timstreater@greenbee.net> - 2018-04-24 10:17 +0000
Re: Is JS a functional programming language? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-04-24 12:02 -0700
Re: Is JS a functional programming language? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-25 05:04 +0200
Re: Is JS a functional programming language? Julio Di Egidio <julio@diegidio.name> - 2018-04-25 02:16 -0700
Re: Is JS a functional programming language? Julio Di Egidio <julio@diegidio.name> - 2018-04-25 02:20 -0700
Re: Is JS a functional programming language? John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-25 18:22 +0100
Re: Is JS a functional programming language? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-04-25 17:25 +0000
Re: Is JS a functional programming language? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-04-25 14:50 -0700
Re: Is JS a functional programming language? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-04-25 14:39 -0700
Re: Is JS a functional programming language? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-29 20:44 +0200
Re: Is JS a functional programming language? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-04-29 13:45 -0700
Re: Is JS a functional programming language? "c.l.js" <trollhunter@curiosity.kills.no> - 2018-04-21 19:51 -0300
Re: Is JS a functional programming language? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-22 01:18 +0200
Re: Is JS a functional programming language? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-22 02:19 +0200
Re: Is JS a functional programming language? "Mark-" <nospam@mapson.xyz> - 2018-04-22 01:52 +0000
Re: Is JS a functional programming language? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-22 04:30 +0200
Re: Is JS a functional programming language? "Mark-" <nospam@mapson.xyz> - 2018-04-22 02:45 +0000
Re: Is JS a functional programming language? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-22 05:55 +0200
Re: Is JS a functional programming language? "Mark-" <nospam@mapson.xyz> - 2018-04-22 04:04 +0000
Re: Is JS a functional programming language? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-22 10:59 +0200
Re: Is JS a functional programming language? John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-22 11:03 +0100
Re: Is JS a functional programming language? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-22 12:50 +0200
Re: Is JS a functional programming language? John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-23 09:19 +0100
Re: Is JS a functional programming language? "Mark-" <nospam@mapson.xyz> - 2018-04-22 12:58 +0000
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-16 10:02 +0100
Re: Trying to create array of object literals Julio Di Egidio <julio@diegidio.name> - 2018-04-16 02:05 -0700
Re: Trying to create array of object literals "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-16 11:27 +0200
Re: Trying to create array of object literals Julio Di Egidio <julio@diegidio.name> - 2018-04-16 02:33 -0700
Re: Trying to create array of object literals "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-16 14:03 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-16 19:40 +0100
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-17 09:45 +0100
Re: Trying to create array of object literals Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-18 03:25 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-18 15:50 +0100
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-18 16:08 +0100
Re: Trying to create array of object literals Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-19 03:34 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-19 10:37 +0100
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-19 19:02 +0100
Re: Trying to create array of object literals Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-19 03:25 +0200
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-16 19:37 +0100
Re: Trying to create array of object literals Julio Di Egidio <julio@diegidio.name> - 2018-04-16 11:48 -0700
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-17 09:52 +0100
Re: Trying to create array of object literals Julio Di Egidio <julio@diegidio.name> - 2018-04-17 03:22 -0700
Re: Trying to create array of object literals John G Harris <niam@jghnorth.org.uk.invalid> - 2018-04-17 18:28 +0100
Re: Trying to create array of object literals bit-naughty@hotmail.com - 2018-04-13 04:08 -0700
csiph-web