Js fundamentals part 1 Modern Javascript


Reassigning vs Redaclaring


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

Reassigning vs Redaclaring


Reassigning 
var hello = "it is me Mirjalol
😊";
Redaclaring 
var hello = "it is me Mirjalol
😊";
var hello = "sorry it wasn't me
😒"
var
hello = "sorry it wasn't me
😒" 


Variables that are declared with var can ba accessed both Global and Function
scope, but once its inside a function scope you cannot call that variable to outside
of a function.
Global scope
var book = 23;


function calculate (a, b) { 
console.log(book) 
}
calculate(); // 23 

Function scope
function calculate (a, b) { 
var book = 23;
}
calculate(); 
console.log(book) 
❌ returns a Reference Error : book is not defined


Types of JavaScript Operators
There are different types of JavaScript operators:
Arithmetic Operators
Assignment Operators
Comparison Operators


String Operators
Logical Operators
Bitwise Operators
Ternary Operators
Type Operators
Arithmetic Operators


Assignment Operators


Comparison Operators


String Operators
String Comparison


Note that strings are compared alphabetically: 
In below it returns true
String Addition
this in above returns "John Doe", there is a space between.


This arrow is showing the space. That is why they are not attached.
Adding Strings and Numbers
In string the + will not do arithmatic. it simply concatinates.


Logical Operators
&& - if all are true, returns true. 
|| - it doesnt matter for this, here even if one of them is true, returns true.



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