๐จ๐ป๐ฑ๐ฒ๐ฟ๐๐๐ฎ๐ป๐ฑ๐ถ๐ป๐ด ๐ง ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐ ๐ถ๐ป JS ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด
In programming, operators are symbols that represent operations performed on variables and values. They are essential in executing arithmetic, comparison, logical, assignment, and conditional operations.
Here are some key types of operators commonly used:
๐ญ. ๐๐ฟ๐ถ๐๐ต๐บ๐ฒ๐๐ถ๐ฐ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐: Used for basic mathematical operations like addition (+), subtraction (-), multiplication (*), division (/), modulus (%), increment (++), and decrement ( โ ).
๐ฎ. ๐๐ผ๐บ๐ฝ๐ฎ๐ฟ๐ถ๐๐ผ๐ป ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐: Allow comparison between values, such as greater than (>), less than (<), equal to (==), strict equality (===), and not equal to (!=).
๐ฏ. ๐๐ผ๐ด๐ถ๐ฐ๐ฎ๐น/๐ฅ๐ฒ๐น๐ฎ๐๐ถ๐ผ๐ป๐ฎ๐น ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐: Used for logical operations, including AND (&&), OR (||), and NOT (!).
๐ฐ. ๐๐๐๐ถ๐ด๐ป๐บ๐ฒ๐ป๐ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐: Assign values to variables, like the simple assignment (=), and compound assignments such as +=, -=, *=, /=, and %=.
๐ฑ. ๐๐ผ๐ป๐ฑ๐ถ๐๐ถ๐ผ๐ป๐ฎ๐น/๐ง๐ฒ๐ฟ๐ป๐ฎ๐ฟ๐ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ: A shorthand for if-else statements, written as โcondition ? expr1 : expr2โ.
(~)๐ฆ๐ฝ๐ฒ๐ฐ๐ถ๐ฎ๐น ๐ก๐ผ๐๐ฒ๐:-
- ๐๐ป๐ฐ๐ฟ๐ฒ๐บ๐ฒ๐ป๐ (++) ๐ฎ๐ป๐ฑ ๐๐ฒ๐ฐ๐ฟ๐ฒ๐บ๐ฒ๐ป๐ ( โ ) ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐: When used before a variable (prefix), they modify the value before using it. When used after a variable (postfix), they modify the value after using it.
- ๐ฆ๐๐ฟ๐ถ๐ฐ๐ ๐๐. ๐๐ผ๐ผ๐๐ฒ ๐๐พ๐๐ฎ๐น๐ถ๐๐: โ===โ checks both value and type, while โ==โ only checks value, converting types if necessary.
- โ๐๐๐ฝ๐ฒ๐ผ๐ณโ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ: A special operator in JavaScript that returns the data type of a variable, such as โstringโ, โnumberโ, โobjectโ etc. Interestingly, it returns โobjectโ for null values.
Understanding these operators is fundamental for efficient programming and debugging. Make sure to use them wisely to maintain clean and effective code. ๐