Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Js Operators in JavaScript

Js Operators in JavaScript

? JavaScript Operators

Operators in JavaScript are special symbols used to perform operations on operands (variables or values). They are the foundation of expressions in JavaScript.


? 1. Arithmetic Operators

Used for mathematical calculations.

OperatorNameExampleResult
+Addition5 + 27
-Subtraction5 - 23
*Multiplication5 * 210
/Division10 / 25
%Modulus5 % 21
**Exponentiation2 ** 38
++Incrementx++x + 1
--Decrementx--x - 1

? 2. Assignment Operators

Assign values to variables.

OperatorExampleSame As
=x = yx = y
+=x += yx = x + y
-=x -= yx = x - y
*=x *= yx = x * y
/=x /= yx = x / y
%=x %= yx = x % y

? 3. Comparison Operators

Compare two values and return a Boolean (true or false).

OperatorDescriptionExample
==Equal to5 == "5" ?
===Strict equal5 === "5" ?
!=Not equal5 != 3 ?
!==Strict not equal5 !== "5" ?
>Greater than5 > 3 ?
<Less than5 < 3 ?
>=Greater or equal5 >= 5 ?
<=Less or equal3 <= 5 ?

? 4. Logical Operators

Combine multiple conditions.

OperatorDescriptionExample
&&Logical ANDtrue && false ? false
``
!Logical NOT!true ? false

? 5. Type Operators

OperatorDescriptionExample
typeofReturns typetypeof 42 ? "number"
instanceofChecks instanceobj instanceof Array

? 6. Other Useful Operators

  • Ternary Operator (Conditional):

    let age = 18;let result = (age >= 18) ? "Adult" : "Minor";
  • Nullish Coalescing (??):
    Returns right-hand value if left is null or undefined.

    let name = null;console.log(name ?? "Guest"); // "Guest"
  • Optional Chaining (?.):
    Avoids errors when accessing deeply nested properties.

    user?.profile?.email;

? Summary

JavaScript operators are grouped into:

  • Arithmetic

  • Assignment

  • Comparison

  • Logical

  • Type

  • Conditional

They help you perform everything from math to conditionals and value checks.


Would you like a cheat sheet or mini quiz to test your operator knowledge?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql