Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #20208
| Message-ID | <3002636.TxiHlyYqki@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-06-11 16:51 +0200 |
| Subject | Re: Alignment of three tables |
| Newsgroups | comp.lang.javascript |
| References | (3 earlier) <b1m8g6Fjnc5U1@mid.individual.net> <b1mfv8Flc2aU1@mid.individual.net> <kp60kh$nrp$1@dont-email.me> <2068082.pen2y8QiGc@PointedEars.de> <XnsA1DC6FC427B06eejj99@194.109.133.133> |
Evertjan. wrote:
> Thomas 'PointedEars' Lahn wrote on 11 jun 2013 in comp.lang.javascript:
>>> cells[j].style.width = "" + pwidths[j] + "%";
>> The algorithm for + makes it unnecessary to concatenate "" here;
>
> 'here' indeed.
>
>> there is no preference in the algorithm towards left-to-right
>> conversion.
>
> not quite correct, Thomas, there is a strong preference:
>
> <script type='text/javascript'>
>
> function f(x) {
> document.write( x + '<br>' + typeof x + '<br><br>' );
> };
>
> f( 4 + 4 + '5' ); // 85
> […]
> f( '4' + 4 + 5 ); // 455
JFTR:
It was rather obvious that I was talking about the algorithm for the
(*binary*, as opposed to unary) “+” operator which only takes *two*
operands. I said, in essence, that because of
| 7. If Type(lprim) is String or Type(rprim) is String, then
| a. Return the String that is the result of concatenating
| ToString(lprim) followed by ToString(rprim)
*both*
4 + "5"
and
"4" + 5
result in
"45"
which is a true statement.
This has nothing to do with the left-to-right evaluation order of
expressions in these languages. The expressions in your examples
are *several* “+” operations, and because of
| The production AdditiveExpression : AdditiveExpression +
| MultiplicativeExpression is evaluated as follows:
|
| 1. Let lref be the result of evaluating AdditiveExpression.
4 + 4 + '5'
is evaluated as
(4 + 4) + "5"
leading to
8 + "5"
and therefore
"85"
Likewise,
'4' + 4 + 5
is evaluated as
("4" + 4) + 5
leading to
"44" + 5
and therefore
"445"
∎
--
PointedEars
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
Alignment of three tables "Mel Smith" <med_cutout_syntel@aol.com> - 2013-06-09 08:49 -0600
Re: Alignment of three tables Scott Sauyet <scott.sauyet@gmail.com> - 2013-06-09 08:18 -0700
Re: Alignment of three tables Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-09 20:02 +0000
Re: Alignment of three tables "Mel Smith" <med_cutout_syntel@aol.com> - 2013-06-09 15:01 -0600
Re: Alignment of three tables Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-09 22:50 +0000
Re: Alignment of three tables Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-10 00:46 +0200
Re: Alignment of three tables John Harris <niam@jghnorth.org.uk.invalid> - 2013-06-10 14:41 +0100
Re: Alignment of three tables Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-10 17:35 +0200
Re: Alignment of three tables "Mel Smith" <med_cutout_syntel@aol.com> - 2013-06-10 09:08 -0600
Re: Alignment of three tables "Mel Smith" <med_cutout_syntel@aol.com> - 2013-06-10 11:16 -0600
Re: Alignment of three tables Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-11 02:05 +0000
Re: Alignment of three tables Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-11 05:09 +0200
Re: Alignment of three tables "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-06-11 10:59 +0200
Re: Alignment of three tables Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-11 16:51 +0200
Re: Alignment of three tables Stefan Weiss <krewecherl@gmail.com> - 2013-06-14 15:38 +0200
Re: Alignment of three tables Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-06-14 20:26 +0200
Re: Alignment of three tables Stefan Weiss <krewecherl@gmail.com> - 2013-06-14 21:22 +0200
Re: Alignment of three tables Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-06-15 00:36 +0200
Re: Alignment of three tables Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-15 12:04 +0200
Re: Alignment of three tables Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-15 11:41 +0200
Re: Alignment of three tables Stefan Weiss <krewecherl@gmail.com> - 2013-06-15 13:53 +0200
Re: Alignment of three tables Scott Sauyet <scott.sauyet@gmail.com> - 2013-06-17 04:28 -0700
Re: Alignment of three tables "Andy" <andy@NOSPAMmanyplay.com> - 2013-06-10 09:19 +0100
Re: Alignment of three tables Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-06-12 18:56 +0100
csiph-web