Operators and Expressions
In JavaScript, operators are symbols that perform operations on operands. Expressions are combinations of variables, values, and operators that produce a new value.
Arithmetic Operators
Arithmetic operators are used to perform mathematical operations. Here are the common arithmetic operators in JavaScript:
- Addition (
+): Adds two operands together. - Subtraction (
-): Subtracts the second operand from the first operand. - Multiplication (
*): Multiplies two operands together. - Division (
/): Divides the first operand by the second operand. - Modulus (
%): Returns the remainder when the first operand is divided by the second operand.
Let's see some examples of using arithmetic operators:
xxxxxxxxxx10
// Arithmetic Operatorslet num1 = 10;let num2 = 5;console.log('Addition:', num1 + num2);console.log('Subtraction:', num1 - num2);console.log('Multiplication:', num1 * num2);console.log('Division:', num1 / num2);console.log('Modulus:', num1 % num2);OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment



