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


Groups > comp.lang.javascript > #32470

Re: Values of statements

Newsgroups comp.lang.javascript
Subject Re: Values of statements
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <statement-20170205003911@ram.dialup.fu-berlin.de>
Date 2017-02-05 10:39 +0100
Message-ID <XnsA7136C6DE3F79eejj99@194.109.6.166> (permalink)

Show all headers | View raw


ram@zedat.fu-berlin.de (Stefan Ram) wrote on 05 Feb 2017 in 
comp.lang.javascript:

> In JavaScript, statements have values.

No, that's too bold a statement!

There is a difference between functions and statements.

Even functions do not 'have' a value, but 'return' a value.

Statements do NOT return a value, 
EXCEPT when a function is used as a statement, as
then it returns a value that is immediately discarded.

alert('hi'); // Statement, no return vanue.

let z = add(2,3); // function [user defined here]

add(2,3); // same function now used as a statement

let z = alert('hi'); // returns 'undefined', for lack of returning a value
alert(z);

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread


Thread

Re: Values of statements "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-05 10:39 +0100

csiph-web