Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7962795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:26:42+00:00 2026-06-04T05:26:42+00:00

The comma operator evaluates each comma-separated operand (and returns the value of the last

  • 0

The comma operator evaluates each comma-separated operand (and returns the value of the last one).

(i = 1 + 2), (j = 3 + 4);

is functionally equivalent to

i = 1 + 2;
j = 3 + 4;

Also, as far as I know, a statement, such as var, is not considered an operator, but rather part of the operand. (See https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence )

So if each operand is being separately evaluated, why, then, does

function foobar () {
    var i = 3, j = 7, z;
}

create 3 variables – i, j, and z – in foobar’s scope?

I know that’s what actually happens, but I’ve been wondering for a while why it is that this actually happens. It would seem that i should be in foobar’s scope, but that j and z should end up in the global scope.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:26:44+00:00Added an answer on June 4, 2026 at 5:26 am

    The commas used in a var statement are not actually comma operators.

    Similarly, the commas you use to separate arguments in a function call are not comma operators either.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The C++ comma operator is used to chain individual expressions, yielding the value of
Possible Duplicate: C++ Comma Operator what is result of operator ',' by standard? Last
I have a table with several fields and one field having 3 Comma Separated
Possible Duplicate: C++ Comma Operator that probably a trivial question, but I don't know
MDN claims that: The comma operator evaluates both of its operands (from left to
is it possible to construct variadic arguments for function by overloading operator comma of
I got this comma separated file with a bunch of numbers The only thing
Remove first comma on each line in a file. I presume sed is needed.
How to check for comma separated values in a text box and raise an
Can anyone please explain the comma operator in FOR statement? function funct_1(c){ for (var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.