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


Groups > comp.lang.javascript > #22453

Re: How to understand return a,b statement ?

From Joao Rodrigues <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: How to understand return a,b statement ?
Date 2013-12-28 16:00 -0200
Organization Aioe.org NNTP Server
Message-ID <l9n3ka$d47$1@speranza.aioe.org> (permalink)
References <ec287c43-ac92-489e-8140-55272ace07bb@googlegroups.com> <1368da15-53d4-457c-9ee1-3e9f90b677d2@googlegroups.com>

Show all headers | View raw


On 28/12/2013 15:03, Guillaume Biton wrote:
> Ok I found my reply here : https://developer.mozilla.org/fr/docs/JavaScript/R%C3%A9f%C3%A9rence_JavaScript#Opérateurs
>
> Comma Operator
> (,)
>
> The comma operator allows multiple expressions to be evaluated in a single statement and returns the result of the last expression.
>
> Sorry for the question
>
> Le samedi 28 décembre 2013 17:57:59 UTC+1, Guillaume Biton a écrit :
>> Hello,
>>
>>
>>
>> I have difficulties to understand the statement :
>>
>>
>>
>> return a, b
>>
>>
>>
>> When I try I always get b value ? Anyone can explain ?

According to Douglas Crockford's book (JavaScript: The Good Parts), the 
comma operator should be used only inside for statements, because it can 
lead to excessively tricky expressions or mask programming errors. 
Thereby JSLint will complain if it finds the comma operator used outside 
the initialization and incrementation parts of the for statement.

However, there are cases in which the comma operator might be useful, 
although the code would become cryptic to other developers who weren't 
familiarised with it.

Check this out:

<http://javascriptweblog.wordpress.com/2011/04/04/the-javascript-comma-operator/>


-- 
Joao Rodrigues

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


Thread

How to understand return a,b statement ? Guillaume Biton <guillaume.biton@gmail.com> - 2013-12-28 08:57 -0800
  Re: How to understand return a,b statement ? Guillaume Biton <guillaume.biton@gmail.com> - 2013-12-28 09:03 -0800
    Re: How to understand return a,b statement ? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2013-12-28 16:00 -0200
      Re: How to understand return a,b statement ? Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-28 20:54 +0000
        Re: How to understand return a,b statement ? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2013-12-28 23:16 -0200
        Re: How to understand return a,b statement ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-29 17:25 +0100
        Re: How to understand return a,b statement ? Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-12-29 18:22 +0000

csiph-web