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 8034155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:55:25+00:00 2026-06-05T01:55:25+00:00

I read an e-book and find this command, but I don’t know it’s purpose

  • 0

I read an e-book and find this command, but I don’t know it’s purpose and when to using it. Example:

var x = (12, 34, 56)

x in this case is a number and it’s value is 56. Thanks.

This is the full script I read from ebook ‘Javascript for absolute Beginners’:

var fridge = {
buttermilk: [1/3, "cup"],
kefir: [1 + 1/2, "cup"],
yogurt: [4, "cup"],
};
var dough = {
hardWhiteWholeWheatFlour: [2, "cup"],
sugar: [1/3, "cup"],
madagascarVanilla: [1, "tsp"],
orangeZest: [1, "tbs"],
soda: [1, "tsp"],
tartar: [1, "tsp"],
orangeJuice: [1/2, "cup"],
culturedMilk: [1/2, "cup"],
egg: [1],
cranberries: [2/3, "cup"]
};
dough.culturedMilk[0] = fridge.buttermilk[0] >= 1/2 ? (fridge.buttermilk[0] -= 1/2, 1/2) :
fridge.kefir[0] >= 9/16 ? (fridge.kefir[0] -= 9/16, 9/16) :
fridge.yogurt[0] >= 10/16 ? (fridge.yogurt[0] -= 10/16, 10/16) :
alert("No cranberry bread for you!");
dough.culturedMilk;
// [0.5625, "cup"]
fridge.kefir;
// [0.9375, "cup"]
  • 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-05T01:55:26+00:00Added an answer on June 5, 2026 at 1:55 am

    It seems you already know what it means… evaluated each operand and return the result of the last.

    In the case of (fridge.buttermilk[0] -= 1/2, 1/2), the expression itself is part of the conditional operator:

    fridge.buttermilk[0] >= 1/2 ? (fridge.buttermilk[0] -= 1/2, 1/2) : ...
    

    In this case, the comma operator is used to introduce side effects. If fridge.buttermilk[0] >= 1/2 is true, then 1/2 should be assigned to dough.culturedMilk[0]. But at the same time, fridge.buttermilk[0] should be updated as well.

    Normally you would use two expression statements, like

    if(fridge.buttermilk[0] >= 1/2) {
        fridge.buttermilk[0] -= 1/2;
        dough.culturedMilk[0] = 1/2;
    }
    

    but since the author wants to use the conditional operator, the comma operator can be used to execute both expression in one expression. It updates the value of fridge.buttermilk[0] and returns 1/2.

    I’m not recommending doing this though, especially in this case, with nested conditional operators, a traditional if-else statement would be easier to read.

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

Sidebar

Related Questions

This is surely a stupid question, but I'm stumped. I've now read Odersky's book,
Recently I read a book( CleanCode ) in this book, FUNCTION SHOULD DO ONE
I've read this book section about git branches. I have create a branch called
I am not a Groovy expert, but I did read the book Groovy in
I read this book: Head First Object-Oriented Analysis and Design Now i am looking
This has probably been asked before but I couldn't find the answer to my
From Accelerated C++ (book), I found this code which is identical program, but the
I am using a perl script to read in a file, but I'm not
I read an online book . It gave an callback pattern example as follow.
I read a book that uses infix, infixr, and infixl in the sample programs.

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.