Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32474
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Values of statements |
| Date | 2017-02-05 18:36 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <3075942.V25eIC5XRa@PointedEars.de> (permalink) |
| References | <statement-20170205003911@ram.dialup.fu-berlin.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 comp.lang.javascript | Previous | Next | Find similar | Unroll thread
Re: Values of statements Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-05 18:36 +0100
csiph-web