A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-comma-operator/ below:

JavaScript Comma Operator - GeeksforGeeks

JavaScript Comma Operator

Last Updated : 15 Jul, 2025

JavaScript Comma Operator mainly evaluates its operands from left to right sequentially and returns the value of the rightmost operand.

JavaScript
let x = (1, 2, 3);
console.log(x); 

Here is another example to show that all expressions are actually executed.

JavaScript
let a = 1, b = 2, c = 3;

let res = (a++, b++, c++);

console.log(res);
console.log(a, b, c); 

Here is an example with function calls.

javascript
function Func1() {
    console.log('one');
    return 'one';
}
function Func2() {
    console.log('two');
    return 'two';
}
function Func3() {
    console.log('three');
    return 'three';
}

// Three expressions are
// given at one place
let x = (Func1(), Func2(), Func3());

console.log(x);

Output
one
two
three
three


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4