Js fundamentals part 1 Modern Javascript


Download 1.18 Mb.
Pdf ko'rish
bet4/4
Sana13.09.2023
Hajmi1.18 Mb.
#1676711
1   2   3   4
Bog'liq
JS FUNDAMENTALS PART 1

Truthy and Falsy Values
Here are the 5 falsy values, so in this picture when we convert to Boolean it is
throwing false, in practise we may not do this, the Javascript itself converts


it(coersion): 


Here is the interesting part, why do you think it is returning true 
Below in that picture, in if statement inside a parathesis the Javascript
automatically converts any value into Boolean: 


Equality operator == vs ===
So what is the difference between these two? 
checks the value itself, on the other hand = checks both value and the type.
===
1.Case: 
2.Case: 
==


1.Case 
2.Case 
The Switch Statement
So when you have many condition to check instead of using if/else statement you
can simply use switch statement.
In this picture, as you can see it is checking whether it is true or false. 
So the break is stopping the exacution of the code. If none of them is true then


default works it is like and else statement. 
The Statement and Expression
Statement is the complete line of the code that does something. e.g: let x = 2 + 2;
is a statement that creates a variable 
x
and gives it the value 
4
.


Expression is the pice of the code that produces the value.
In this picture the whole const variable is the statement, the string ("23 is bigger
here") is the expression. 
Ternary Operator
It is the easier version of using if/else statement like for making quick decisions.

Download 1.18 Mb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling