#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:
- if statement: Executes a block of code only if a specified condition is true.
- if...else statement: Executes a block of code if the condition is true, and another block of code if the condition is false.
- 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
- Write a code to check person is adult or not
- Write a code to check number is even or odd
- Using Switch Statement Check number is divisible by 5 and 15
Beginner's javascript Course in Hindi | 2023 | Javascript Course for Beginners in Hindi Complete Notes of JS - https://dosomecoding.com/courses/javascript/javascript-hindi-course-for-beginners Javascript Beginners Playlist Link - https://www.youtube.com/playlist?list=PLPppPPmk0i3gZCY8JZ0H5oykFGevvNzNS Linkedin - https://linkedin.com/in/anshuopinion Telegram Channel - https://telegram.me/dosomecodinghelp Instagram - https://instagram.com/dosomecoding Github - https://github.com/anshuopinion HTML Course https://www.youtube.com/playlist?list=PLPppPPmk0i3gL2isb9Kr1GvTM8id2gdtY CSS Course https://www.youtube.com/playlist?list=PLPppPPmk0i3gWK5TVILnKSvuc9Fc15sbH Html and CSS practice Projects https://www.youtube.com/playlist?list=PLPppPPmk0i3hZCNmbVtcP1hlwDKOdUFX9 Javascript Course https://www.youtube.com/playlist?list=PLPppPPmk0i3gZCY8JZ0H5oykFGevvNzNS Linkedin - https://linkedin.com/in/anshuopinion Telegram Channel - https://telegram.me/dosomecodinghelp Instagram - https://instagram.com/dosomecoding Github - https://github.com/anshuopinion