Javascript provides a wide range of operators to perform various operations, from simple arithmetic to complex logical expressions. Here is an overview of the key categories of operators in JavaScript
-
Addition(‘+’): used to add two numbers or to concatenate strings.
-
subtraction(‘-’): used to subtract one number from another.
-
Multiplication(‘*’): used to multiply two numbers
-
Division(‘/’): used to divide one number with another
-
Reminder(‘%’): used to return the remainder from a division operation.
-
Exponentiation(‘**’): used to raise a number to a power.
Assignment operators are used to assign values to variables.
-
Simple Assessment(‘=’): used to assign a value to a variable.
-
Combined Assessment Operators: perform an arithmetic operation and then assign the result to a variable.
-
Add and Assign(‘+=’)
-
Subtraction and Assign(‘-=’)
-
Multiply and Assign(‘*=’)
-
Divide and Assign(‘/’)
-
Remainder and Assign(‘%=’)
-
Exponentiation and Assign(‘**=’)
Comparison operators are used to compare values and return a boolean(‘true’ or ‘false’)
-
Equality(‘==’) and strict Equality(‘===’):’==’ checks for equality with type conversion, while ‘===’ checks for equality without type conversion.
-
Inequality(‘!=’) and strict inequality(‘!===’)
-
Greater Than(‘>’) and Greater than or Equal To(‘>=’)
-
Less Than(‘<’) and Less than or Equal To(‘<=’)
Logical operators are used to perform logical operations on boolean values
-
Logical AND(&&): returns true if both conditions are true
-
Logical OR(‘II’) returns true if one condition is true
-
Logical NOT(‘!’): returns the negation of a boolean value
The ternary operator is a shorthand for if-else statements.
-
Comma Operator(‘,’): Evaluates multiple expressions and returns the last one.
-
Typeof Operator(‘typeof’) returns the type of valuable
-
Instanceof Operator(‘instanceof’): checks if an object is an instance of a specific class or constructor.
These are the primary operators in JavaScript.Understanding their functionality and how to use them effectively is essential for writing effective and efficient JavaScript code.