Operators
- Operators are symbols or keywords used in programming to perform operations on data, such as mathematical calculations, comparisons, and logical evaluations. They act on operands (variables or values) to produce a specific result, forming the foundation of data manipulation.
Arithmetic
- Arithmetic: Used for math, including addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
Assignment
- Assigns values to variables, such as = and compound operators like +=, -=, or *=.
Comparison Operators
These operators are used to compare two values
and then returns boolean values (true or false).
- == (Equal value, with type coercion) === (Equal value and equal type; always prefer this strict equality) != (Not equal value) !== (Not equal value or not equal type/ Strict not equal) > (Greater than) < (Less than) >= (Greater than or equal to) <= (Less than or equal to)
Logical Operators
- These operators are used to combine or modify boolean expressions. && (Logical AND) || (Logical OR) ! (Logical NOT) ?? (Nullish coalescing, returns the right operand if the left is null or undefined, otherwise returns the left).
Other Operators
String Concatenation Operator (+): When one of the operands is a string, the + operator concatenates the strings.
Bitwise Operators: Perform operations on the binary representations of numbers (e.g., &, |, ^, ~, <<, >>, >>>)
- Conditionals
Use if to specify a code block to be executed, if a specified condition is true
Use else to specify a code block to be executed, if the same condition is false
Use else if to specify a new condition to test, if the first condition is false.
Top comments (0)