Skip to main content

Command Palette

Search for a command to run...

03. BASICS | Operators in JavaScript

This article will talk about all the operators available in javascript.

Updated
2 min readView as Markdown
S
Full-Stack Developer with 4 years' experience, specializing in backend development. Skilled in JavaScript, React, Python, Databases, and AWS. Known for building scalable web apps, leading teams, and maintaining strong client communication. Upskilling in Generative AI.

Arithmetic Operators

+ // Addition
- // Subtraction
* // Multiplication
** // Exponent
/ // Division
% // Modulus
++ // Increment
-- // Decrement
// prefix
++count // it will first increase the value of count and then use it
--count // it will first decrease the value of count and then use it

// postfix
count++ // it will first use the value of count and then increase it
count-- // it will first use the value of count and then decrease it

Assignment Operators

= // x = y
+= // x = x + y
-= // x = x - y
*= // x = x * y
/= // x = x / y
%= // x = x % y
**= // x = x**y

Comparison Operators

== // equal to
!= // not equal to
=== // equal value and type
!== // not equal value OR not equal type
> // greater than
>= // greater than or equal to
< // less than
<= // less than or equal to

Logical Operators

&& // logical AND
|| // logical OR
! // logical NOT

Bitwise Operators


Other Operators

1. Nullish Coalescing Operator (??)

Used to handle null or undefined value.

let x;

x = 5 ?? 10; // x will contain 5
x = null ?? 10; // x will contain 10
x = undefined ?? 5; // x will contain 5
x = null ?? 5 ?? 10; // x will contain 5

Happy reading!