Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32474 > unrolled thread

Re: Values of statements

Started byThomas 'PointedEars' Lahn <PointedEars@web.de>
First post2017-02-05 18:36 +0100
Last post2017-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.


Contents

  Re: Values of statements Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-05 18:36 +0100

#32474 — Re: Values of statements

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-02-05 18:36 +0100
SubjectRe: 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.

[toc] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web