Comma Operator
The comma operator allows execution of more than one operation in a single statement:
var num1=1, num2=2, num3=3;
When comma operator is used in assignment statement, the comma operator returns the last item:
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var num = (1, 2, 3, 4, 5);
document.writeln(num);//num is 5
</script>
</head>
<body>
</body>
</html>
Home
JavaScript Book
Language Basics
JavaScript Book
Language Basics
Operators:
- JavaScript Operators
- Increment/Decrement Operators
- Increment/Decrement Operators for String, Boolean, Floating-point and Object
- Unary Plus and Minus
- Bitwise Not operator
- Bitwise AND
- Bitwise OR
- Bitwise XOR
- Left Shift
- Signed Right Shift
- Unsigned Right Shift
- Logical NOT
- Logical AND
- Logical OR
- Multiply
- Divide
- Modulus
- Add
- Subtract
- Relational Operators
- Equal and Not Equal
- Identically Equal and Not Identically Equal
- Conditional Operator
- Assignment Operators
- Comma Operator