#3 Operators + Conditional Statements | Javascript Hindi Course For Beginners ( 2023 )

 

Operators

Arithmetic Operators

Name
Symbol
Addition
+
Subtraction
-
Multiplication
*
Division
/
Modules
%
Power
**
Increment
++
Decrement
- -
 

Assignment Operators

Shortcut
Full Expression
=
a = b
+=
a = a + b
-=
a = a - b
*=
a = a * b
/=
a = a/b
**=
a = a**b

Comparison Operators

Symbols
Explanation
==
Equal to
!=
Not equal to
===
Strict equal to ( type checking also )
!==
Strict not equal to ( type checking also )
<
Less than
>
Greater than
<=
Less than and equal to
>=
Greater than and equal to
 

Logical Operators

Symbols
Explanation
&&
Logical AND
||
Logical OR
!
NOT
AND Logic ( && )
Value 1
Value 2
Output
true
true
true
true
false
false
false
true
false
false
false
false
OR Logic ( && )
Value 1
Value 2
Output
true
true
true
true
false
true
false
true
true
false
false
false
NOT Logic ( ! )
Value 1
Output
true
false
false
true
Bitwise operators perform bit-level operations on numbers. They are used to manipulate individual bits in an integer. You can skip this topic .

Conditional Expressions

conditional statements are used to make decisions based on whether a condition is true or false. The most commonly used conditional statements are:
 
  1. if statement: Executes a block of code only if a specified condition is true.
  1. if...else statement: Executes a block of code if the condition is true, and another block of code if the condition is false.
  1. switch statement: Selects one of many blocks of code to be executed based on multiple conditions.
 
if statement
 
How if condition works
Lets see if you want check certain condition, if that condition meets requirements then you want to execute that code.
if statement get condition true then it executes is code.
 
 
 
if else statements
How if else statements works
See When if Statement code is not executed then else block is automatically get executed,
else block provide fallback case. if any thing went wrong then else block will get executed
 
else if statements
In some cased you need to check multiple condition , in that situation you need to use
else if statements.
 
 
Switch Statements
A switch statement in JavaScript is a conditional statement that tests an expression against multiple cases and executes the code associated with the first matching case. If no cases match, a default case can be specified to execute. The switch statement provides a cleaner syntax and improved readability compared to a series of if-else statements.
 
Shortcut of if Else - Ternary Operator
 
 
 
 

Questions | Solve them

  1. Write a code to check person is adult or not
  1. Write a code to check number is even or odd
  1. Using Switch Statement Check number is divisible by 5 and 15