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


Groups > comp.lang.javascript > #35948

Re: comma operator?

From Luca <luca@please.nospam.it>
Newsgroups comp.lang.javascript
Subject Re: comma operator?
Date 2019-01-02 08:17 -0500
Organization Aioe.org NNTP Server
Message-ID <q0idkl$1195$1@gioia.aioe.org> (permalink)
References <q0gsa4$iad$1@gioia.aioe.org> <eaaa8ad7-5a86-489e-b606-74e1fa8f7221@googlegroups.com>

Show all headers | View raw


On 1/2/2019 3:32 AM, Abhinav Sharma wrote:
> On Wednesday, January 2, 2019 at 4:45:23 AM UTC+5:30, Luca wrote:
>> Not sure how to google for this. What's the use of the comma operator
>> used like this in JS?
>>
>>    let matrix = [], row;
>>
>> I am studying this React.js example and the construct above is puzzling me.
>>
>> https://github.com/danielr18/memory-grid-game/blob/master/lib/Game.js#L18
>>
>> thanks
> 
> You can declare multiple variables separated by comma on a single line.
> Although not a preferred way to do so as per common style guides for javacript.
> 

yeah, I get it now. What was confusing me was probably a Python 
interference. I was interpreting this as some kind of:

   let matrix = ([], row);

:)

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


Thread

comma operator? Luca <luca@please.nospam.it> - 2019-01-01 18:15 -0500
  Re: comma operator? Luca <luca@please.nospam.it> - 2019-01-01 18:24 -0500
    Re: comma operator? rbowman <bowman@montana.com> - 2019-01-01 17:09 -0700
      Re: comma operator? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-01-02 09:34 +0100
  Re: comma operator? Abhinav Sharma <a.sharma.nitk@gmail.com> - 2019-01-02 00:32 -0800
    Re: comma operator? Luca <luca@please.nospam.it> - 2019-01-02 08:17 -0500

csiph-web