๐จ๐ป๐ฑ๐ฒ๐ฟ๐๐๐ฎ๐ป๐ฑ๐ถ๐ป๐ด ๐๐ฎ๐๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐ JavaScript operators are special symbols used to perform calculations and make comparisons in your code. They act on values known as operands.
You can use operators to perform operations on values and variables. JavaScript operators are categorized into groups:
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Relational Operators
Arithmetic Operators are used to perform mathematical operations like addition and subtraction.
- Addition: 2 + 1 = 3
- Subtraction: 4 - 1 = 3
- Multiplication: 5 * 2 = 10
- Division: 10 / 2 = 5
- Remainder: 10 % 3 = 1
- Exponentiation: 10 ** 3 = 1000
- Increment: ++x increases x by 1
- Decrement: --x decreases x by 1
Assignment Operators assign values to variables.
- = assigns a value to a variable
- += adds and assigns the result to the variable
- *= multiplies and assigns the result to the variable
Comparison Operators compare one value or variable with something else.
- == checks if two values are equal
- != checks if two values are not equal
checks if a value is greater than another
- < checks if a value is less than another
= checks if a value is greater than or equal to another
- <= checks if a value is less than or equal to another
Logical Operators check whether one or more expressions result in true or false.
- && returns true if both operands are true
- || returns true if one operand is true
Relational Operators compare operands and determine the relationship between them.
- in checks if a property exists in an object
- instanceof checks if an object is an instance of a constructor
Source: https://www.freecodecamp.org/news/javascript-operators/ Optional learning community: https://dev.to/kamalesh_ar_6252544786997/understanding-javascript-operators-with-examples-42ne