JavaScript Operators: The Basics You Need to Know

I have joined and started learning Software development with ChaiCode Web dev Cohort 2026 and very excited😊
Search for a command to run...

I have joined and started learning Software development with ChaiCode Web dev Cohort 2026 and very excited😊
No comments yet. Be the first to comment.
this series includes all about Javascript which I will learned in Chaicode Webdev cohort 2026.
Array 101: The Absolute Beginner’s Guide to Data Structures
Lets differentiate and understand about global and globalThis used in nodejs or any JS ecosystem like whether it will be in browser , nodejs, deno, web workers etc. What is global ? global means glo
Lets learn about path module of nodejs path module helps to get files and directory and works with it and write code for cross platform code . like getting files from any operating system like macos,
The virtual DOM is a lightweight copy of the real DOM that allows React to manage changes more efficiently by minimizing the direct manipulation required on the real DOM. This process significantly en
About template literal , use case and reasons of bringing it and benefits

why do it need to flatten array and various ways of flatten the array

In programming , we need to do some operation with data, calculation and store the result. example : for mathematical calculation we use arithmetic operators like +, -, *, /, %. It is used for logic building and calculation. In JavaScript, The operators is just function that takes parameters which called operand, there are types of operators like Binary, Unary or Tertiary.
Every operators return different type of data.
Arithmetic operator : It is just mathematic operator. It is used for basics math operations like addition, subtraction, multiplication, division and remainder.
Comparison operator : It is used for comparing data. It is used for making decision and it return Boolean. like > , < , >=, <=,!==
Assignment operator : It is used for assigning data like =, +=, -=, *=,++, --
Logical Operator : This is used for combining logics in conditionals using || , &&, !
// addition
let a =2, b = 3;
console.log(a+b) // 5
console.log(a-b)// -1
console.log(a*b)// 6
console.log(a / b) // 0.666
console.log(a % b) // 2
// comparison like >, >=, <, <=, ==, ===, !==, !=
let a=1, b=2;
// greater than
console.log(a > b) // false
// less than
console.log(a < b) // true
// greater than equal
console.log(a >= b) // false
// less than equal
console.log(a <= b) // true
// double equal
console.log(a == b) // false
// triple equal
console.log(a === b) // false
// not equal to
console.log(a !== b) // true
// logical operator
// want to make decison like after 4 baje wakeup
// between 12 and 4 sleeping
let age = 20
if(age >=18)
console.log("You can give vote")
else
console.log("You are not allowed to give vote")
// assignment
let a = 10;
console.log(a +=20) // 30
console.log(a -=20) //10
console.log(a *=20) //200
console.log(a++) //200
console.log(++a)//202
console.log(a--) // 202
console.log(--a) //200
Operator precedence determines the order in which operators in an expression are calculated. This is similar as PEMDAS / BODMAs.
It also depends upon associativity of operator . It is of two ways : left to right and right to left.
// operator
let a=b=10 ;
// here value of a =10 and b=10;
// first b =10 and
// then a = b which is 10
// this is associativity which is right to left
let result = 2 + 4 ** 3 //
// first exponential done which is ** 3
// addition done
// this is operator precedence ** has high precedence than +
// Note simple for no confusion just used parens () for grouping
let sum = 2 + 5 + (3 * 2)
double equality is loosely equality so it doesnot check type it only check value like 2 =="2" JS do coherce on data due to this many bug arise so we try to use === instead of == . === is strict equality so it check both type and value so it is reliable and most used instead of ==.
operator is used for logic building and solving calculations and return the results. There are many operators for the different purpose and it return different type of data which make easier to process and used the data for logic building.