Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32474 > unrolled thread
| Started by | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| First post | 2017-02-05 18:36 +0100 |
| Last post | 2017-02-05 18:36 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.javascript
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Values of statements Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-05 18:36 +0100
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-02-05 18:36 +0100 |
| Subject | Re: Values of statements |
| Message-ID | <3075942.V25eIC5XRa@PointedEars.de> |
Stefan Ram wrote:
> In JavaScript, statements have values.
In all ECMAScript implementations.
> For example, the if statement has a value and thus it is very similar to
> the ternary operator.
>
> const name = a =>
> { "use strict";
> return eval
> ( "if( a === 0 )'Null'; else if( a === 1 )'Eins'; else 'Zwei';" ); }
> undefined
>
> name( 0 )
> "Null"
>
> name( 1 )
> "Eins"
>
> name( 2 )
> "Zwei"
>
> But can something like the above be written without »eval«?
Yes.
> (I.e., can the value of an if statement be obtained without »eval«?)
No.
--
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 top | Article view | comp.lang.javascript
csiph-web