๐จ๐ป๐ฑ๐ฒ๐ฟ๐๐๐ฎ๐ป๐ฑ๐ถ๐ป๐ด ๐๐ฎ v๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐ 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 divided into several groups:
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Relational Operators
Arithmetic operators perform mathematical operations like addition and subtraction. For example: let x = 3; let y = 8; console.log(x + y); // 11
You can use operators directly on values: console.log(2 + 1); // 3 console.log(4 + 1); // 5
Some arithmetic operators include:
- Addition: +
- Subtraction: -
- Multiplication: *
- Division: /
- Remainder: %
- Exponentiation: **
- Increment: ++
- Decrement: --
Assignment operators assign values to variables. They can also perform operations like addition or multiplication. For example: let n = 10; n += 5; n *= 2; console.log(n);
Comparison operators compare one value or variable with something else. They return a boolean value: either true or false. For example: console.log(9 == 9); // true console.log(9 != 20); // true
Logical operators check whether one or more expressions result in either true or false. For example: const a = true, b = false; console.log(a && b); // Logical AND console.log(a || b); // Logical OR
Source: https://www.freecodecamp.org/news/javascript-operators/ Optional learning community: https://dev.to/kamalesh_ar_6252544786997/understanding-javascript-operators-with-examples-42ne