Js fundamentals part 1 Modern Javascript


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

Operator Precedence
The order of exacutation.


But we can change the order with parentheses ()
Strings and Template Literals
String is a data type, which is a value. We store strings to a variable with quotes,
single quotes and backticks


Single quotes
var book = 'Halol Luqma'; 
Double quotes 
var followers = "Double quotes"; 
Backticks 
Which one should i use? Here i am gonna explain to u 
1. Case:


2. Case: 
3. 
Case:
4. 
Case:
5. 
Case:


If you use Backtics 
Well with using backticks u dont have to worry about single and double quotes cos
it is gonna be ok
😊No errors!
Template Literal
Below in that picture you will see the power of Template literals 
If else statement


IF 
else 
again in above picture you can see the power of template literals 
so the else statement is an optional, you can use acording to the situation.
else if 
So if you have multiple statements to compare you can use else if as many times


as you want: 
Type Conversion and Coersion
Type conversion we manually convert the data type of value. 
Coersion is the Javascript automatically converts the type for us.


Type Conversion 
As you can see in below picture it is concatinating. 
We manually converted here: 
Well, well, well, here is the interesting part, hope you realized:(in case, u didnt
realize, it didnt convert deeply, it is still a string) 


Here you cannot do this, as you know it is meaningless even converting string into
number: 
You can convert Number into String, if you need ofcourse : 
Type Coersion 
In above and in below picture the Javascript automatically converting the type of
values: 


So if you remember only + addition concatinates strings but when it comes to
other operators it simply does arithmatic, it is no longer string, it is number: 

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