JavaScript
    About Lesson

    Arithmetic operators are symbols that represent computations like addition, multiplication, and division. JavaScript supports several arithmetic operators, including:

    • + (Addition)
    • - (Subtraction)
    • * (Multiplication)
    • / (Division)
    • % (Modulus)
    • ++ (Increment)
    • -- (Decrement)

     

    How to Use Arithmetic Operators

    Here’s a brief explanation of how each operator works:

     

    Addition (+)

    The + operator adds two numbers together.

    let sum = 5 + 3; // sum will be 8

     

    Subtraction (-)

    The - operator subtracts one number from another.

    let difference = 5 - 3; // difference will be 2
    

     

    Multiplication (*)

    The * operator multiplies two numbers together.

    let product = 5 * 3; // product will be 15
    

     

    Division (/)

    The / operator divides one number by another.

    let quotient = 6 / 3; // quotient will be 2
    

     

    Modulus (%)

    The % operator returns the remainder of a division operation.

    let remainder = 7 % 3; // remainder will be 1
    

     

    Increment (++)

    The ++ operator increases a number by 1.

    let num = 5;
    num++; // num will be 6

     

    Decrement (--)

    The -- operator decreases a number by 1.

    let num = 5;
    num--; // num will be 4

     

    JavaScript’s arithmetic operators are fundamental to performing mathematical operations in your code. They are essential tools in every developer’s toolkit.