Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In JavaScript what is a ',' in a conditional

In this example:

for (var c = 0, e = a.length; c < e && !(d = b(c, a[c]), !1 === d)

And in this other:

if (d = b(c, a[c]), !1 === d)

Do those conditions return the first part, the second or both?

like image 682
kilkadg Avatar asked Jan 16 '13 16:01

kilkadg


People also ask

What is a conditional in JavaScript?

Conditional statements control behavior in JavaScript and determine whether or not pieces of code can run. There are multiple different types of conditionals in JavaScript including: “If” statements: where if a condition is true it is used to specify execution for a block of code.

Which is the conditional operator * :? If ?: If else?

Conditional or Ternary Operator (?:) in C/C++The conditional operator is kind of similar to the if-else statement as it does follow the same algorithm as of if-else statement but the conditional operator takes less space and helps to write the if-else statements in the shortest way possible.

What does a question mark mean in JavaScript?

The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark ( ? ), then an expression to execute if the condition is truthy followed by a colon ( : ), and finally the expression to execute if the condition is falsy.

How many types of conditions are there in JavaScript?

We have four types of conditional statements in JavaScript: An if statement executes a specified code segment if the given condition is ''true.


1 Answers

It is the comma operator, and is not specific to conditionals or loops.

like image 93
Niet the Dark Absol Avatar answered Sep 20 '22 06:09

Niet the Dark Absol