JavaScript Operators

JavaScript has a number of operators that you can perform operations on expressions. The symbol is used in an expression with either one or two values to perform an operation, and return a result value. The expressions that the operators operate on are called operands.

JavaScript Operators

JavaScript supports unary operators, binary operators and one ternary operator to manipulate the data in your programs. Operators that work on only one value are called unary operators. Ex: increment operator (++). Binary operators that require two expressions to perform an operation. Ex. most mathematical operators are binary operators (+ Addition). Ternary operator, which requires three expressions to manipulate the data in your programs.

example

Ternary operator is frequently used as a shortcut for the if..else statements

Commonly used operators and description

JavaScript Operators

Operators in JavaScript can be grouped into several categories and some are follows:

  1. Arithmetic Operators:Perform mathematical calculations
  2. Assignment Operators:Assign or set values to variables
  3. Comparison Operators:Compare values
  4. Logical Operators:Logical operations like AND and OR

Arithmetic Operators

Arithmetic Operators

Assignment Operators

Assignment Operators

Comparison Operators

Comparison Operators

Logical Operators

And (&&), OR () and NOT (!) are Javascript logical operators and they return a Boolean value.

AND (&&) : Allows you to check if both of two conditions are met

example

OR () : Allows you to check if one of two conditions are met

example

NOT (!) : Allows you to check if something is not the case

example