Fox Exomple=
Nas Read = Bu; tulbeof(Read y,
Non Eot= False; Boolean
Prine tales Asn Come as à aault of
Comb aais ons.
Fox Examble:- ___ @ programmer —
Vos X21 ,b=4 ;
console. Leg (za) Louthut
an eee by )
= (Double men A = Known as +e
8. abstract Compasison obmatns
It Combare variables ignores. datatype.
== Tniple equals oberatos.) <= Known as the
Combarisan ojpenaton .
oro Variables as well_datatype.
FA —Tauthy and. Falay Values
Tt iso value thot is considered
“nue when encountered in a Boolean Context
Example :-
typ, $4,079,425 to", K pulse‘,
new Date), =42, 125 3.14, -3.14,
AA —Tnfinity , fer
a programmes qi
L Tr is a value that is considentd
(ils ben encountered in a Boolean context
| Example-== jh =
un
Undefined » nulls FA false, >
0, -0, on (Bigrub)
Vas values = 424 ee
if (values) E
222 Console De. 3 Me
RENTE Buta
—+ u Se =
Console. Log (Jalse);- u
Hut nun à 4
Control Elow
Dcartsobeoux Te allows ous progam to
make decisions about what code 18 executed
___! and when ar nl
AAA
EN
ya
N
N
| ER Im
RN
ie an, is it ie pont osdes ]
Jed inte Bt? 7
i Oran ojal.
Control Flow have two ty ber of Statements
— Ay Conditional Statements”
1 ehe Statements
A
t= Conditional stotements
| año basically, checks +o sec if a certain
condition 1% eithes true on false: TP the
| condition is true then Aun code Ay if its
false then und code 8.
Hangs 8
V yes Ca
ie Statements > Tfelse, äplelse if
Switch ne
:- To perfesm sobetitive task
with fess code.
a — Suite Statement
de exluntes am exp
Combase. ita fault with case values and Dee
| the Statement associated with the matching Cage
ie Susitch Cexpaession) 7
TN te
eu of cases.
breaks ~
| Casevalue 2: - @pnagsammer zur
mec ef Casez __
Er ela
{bods of default 3
o res A +o end
—the Set Switch statement.
- — play dene ahi ee
iA optional
1.4 est
Fon. Loop
= fom York executes a black of code
as Song as a sbeciPied Condition is true
psy na @ptrasammen-otnl
| fon initializer s Cond tian 5. ite
T
I stotemencts
Il 3
> | Intializent:- T+ is oh expression Hal initialize
the Loop executed once -
? || conditiom:- Tt iso boolean expression. that
+ determines whether the Jon fools should
execute on Sols.
|
> | THeroton:- Fon statement executes the. iterotor
„after each iterotion.
|
4 =
24 ede a 4
pe o font Wh ie 2; (244 41) E
| — Congole- Lg (D Fa:
While ‚Da tihile fobs
tahibes tools t= While loop executes Stotements
Da Nong as he" Conditions On. tue. Tf the
——| Condition become false „the Lonh is terminated.
De 3 while Condition) Y
aes U statements
__|Daswhillenbosb< Tn Do while loop the block
of cade. executed once euen before ganz,
+he Condition.
do Y E
statements
3 while (condition) EN
Goran
ss @ paogsamne gin!
A JavaScript Funckions
Eindtionz- A function isa black of code that
het task.
DER
—function_funName U) X
= _Jkstotements
Eee is declamd using the function
heat: Function la
= N BE.
Br: % a
function funName OF
Statements
5 nue
funNome 053 Call Function
| example — 2 ee ta
LIRE —_——funckion_mylame Of > Declane Fun-
a Console. se il ODE
| royNeme ()3 > Function call
output: Srily
| Easy +o understand
Eunchion Aiyumatss- When we «declare function
ne. res the parameters sé
and netusns removed element
— from an et :
tet num = [12:5,uJ5 >
(et nemovednum = _hum.shift();
Console -Lo m); {1 2,3,41
me console. dog Loemouednum)s EN
| @pnogrammer -ginl-.
+ adds: elements to the
Suche beginni: 2) on aaa
let num = 01,252,475
log (num -unshiftCo));
il To,1,2,3,41
Li Array Sant) io TH Aosta the items of anos
let hum = [0,254,175 EM
| Console dog (num-sontt)),;
SES) A COB
_—A Anna nevease O i= Tt netuans the neverse
+ items of an i
0% mil) 25450 |
__Console fog ( num, neverse ());
= | Pres,
>| Access dato...
pe Console Log ( peñson.natne) ; Il toder
Console tog. ( peasoniage); Il zo __
Aisne El det notation
Add key-value pain to objects
= | = pensons id = 5;
—— Console. log ( persoh)};
É u U name: coder”, age: 20, id: s 3
Bruta cad Annckennratien
Const pernson= Y
E — nome Coden? 3
“person age: 223
4
fey aid as a_stg by default.
Let? access’ data by PP
——Lonsole. pau D ‘name” 1);
IL output =
PSE] 3
Tn above example there ts o key named aa
“pessen age” el access it 10 dot Notation
| dot Nototion= Console leg pesson. rason age);
pa = Pre ek e#hon Be hot
include = between name.
Baacket Notabion:= Ed lan persons peson agé yD
Tt wonks because it Ÿ
le no.
paper gil SES —
nn :
Je a a,
=I + last name + Pe
ne | age: 2 (O prog samme. a
NN y
gee tote ke in. His pay era
= en u A outbut:- firstname
ANTE aceenes S44 S lastname.
a BUS | ir ee.
| Console . tg qosint se) U autbut:
U Tt access 1} progsammes
209 5015 gi
ell cme
a ” ,_peason Cee),
Tt access U 2 output: ise
AA „2 Inatname: al
— à
A Fa
3 This method war introduced
_ lin Est. TE takes an object and artusns
On_anhoy xf the. object properties. (key)
—|| Epa. Examble :—
= a Consale “log Cobject keys ( pesson));
Be lo viele
CS erartname”, € Dastname’, “age”
> 3
Object. values) :- It takes an object and
— | Aetuans an ca e A object Valuer.
Eos FT 2 engine gal. =
= __Consol ES values (pesson);
E en
ce , aint? 6719]
PR a 21
—|lObjectuentales O :- Tt takes an object and
e Aetusns the key- Value pain: es
= pa in
consobe.tog class) J) 6
No class Rupee person object ‚Then
1 RE Da ae he class.
_ Aso Function *— Another way do white a function
Tt is Tntnoduced in the ESG version of Ts
| THs Syntax la Ahortes +han Aequlas Function
Y
—__|}Example:- —— Function Exbxession
let add = function (a,b)?
ae ——— —feeduan ath;
KA E
Abpve Codo perds arrow function
let Madd = Coy dt
setusn ty 5,
| iC ee nn + à
—| [Function "with, -pokametes’ —___
pee (pa) > 3 statements? 11 Syntax 4.
i pi > { Stotements A Il ss Ered
A ae me quete
tas Opt I aye
Aetuxn
Capa gal
ee
A ——
ses
= T+ is a behavior. in which a function
los a Variable can be used before declaration
en.) name); ILundepinedl
Ha var name = SE ey zits,
[tt dont Cause on enzor. Because it looks
{| like in execution phase+-
Ele Nan: name, Gpsspaonmer- gil =
= a orme
Nor name= ‘x; yes
„In cose ef let key: y
—|____Console tag (names 11 Reference Essos
I. Fig Nowe Kaya”
: | Tt cause on efron - Tn Case of (ets Variable
— is 12 hoisted but not initialized.
In case. of eel kedo
— Console Log name); I) Ennor
— Const hame = xu 27;
— Conelusion:- (et and const variables ane hoisted
Rule Cannot be acceased before +heis declaratiin
“Conclusion: TauaScaibt: doraht hoist the function
expressions and arrow functions.
ent ahe -
Haxical Scope:= "It means thot a variable defined
—| Outside a function Can be accessible inside
(another function defined after the variable
declasotion. But the cbbosite is not true.
dao boat re add Or
— Vor x= u, am ig hot accessible
cin au ICT ÉRMRS
ti x is accessible he, y 1s Ne
function minus O) x
Nas = 65 > ia accessible
| nf A
= Bk @pregrammertaini -
1 a Ge a
| niotes= he variable. defined. inside. a qunction_—#®
will not be accessible outside the function
In above : code. ia not accesaible
ea tiers tt er the function. __
Block Scobe vs Function Scabe
Block Scobe
Eünchian"Seope.
Tt means that the
Variable is accessible
| within +he block I }.
1 I+ means thot the
| Vamables ane onl,
accessible in the ~
pue
let and Const aro.
function in which
thes ono declared
Nos. is a Function
block Scope- Seche.
| Fon Example Fon Eyample~
fon Cletizo3 (co; i428 | Function fun O Y
11 Block von = 425
& 1 i
Console! itu TT de
| we ane trying to Consele-lo
„access let “variable We. Cannot access var
L outside the Scope. outside the function Scobe] |
Default Pamea- Tt allows us to give default
= pa A Pañametens if no values
Default parametas
a He
ECN artuxn =
| gs
Console. Dog (add t3,u)); 117
a console. Ag Cadet 53); ILX2S,4=22 4
ps - RETA (add (3); Jet, 42293
no: à parameter has A value is undefined
Er Exomble:- holies
“function add oot 1107
"AR Console. La ae
| ee _
Y rl = imi
ail Organ ag
|
Westiftnaemetenas u ia used to gathes parametens
and put them oll_in an asno.
Let's understand with an exomple:=
— function test
Eh — console. Log Ca; lie > outbut
= ° Console dog CH); ia > output
— E 4
DU el tus CS; a);
- testa, 4,4, 6,55
What vill habben with 4, 6,57 2 oobs Nothing
To Cover 3,65 (Rest parametzsa Concept Canes)
Sind ale pus Rest parameter
function test (a, i na,
Aa 11. conaslestan la);
= Console Leg Bd: _
2 RENE
+ dests,a,4,6,5);
{output = 8
8 Couple. of Spec fie
past BR pass os on.-parameter to the
oo. ‚not in_entins object.
—— > Const uses =Y
43 “name? : ‘Alex’,
Ss ur +: {sx QE ali 70? Parom.
— APP 2 det
A O usendetaids ( Lhame, gaed)
Bu nei x
aber Console bo,
raole . La Ca
| CS DS
| = rn —
| —_userdetaits( 9; a
LEA Ed tandis si
| E Alex Re
= Ant sr
L “CallBack Function
Lcallbock function:= Tt is defined as, we can alsn
Boss a function as an exce too function.
Y pinction Second (name?
Console og (name);
__Piunetion_finkt ( callback) E
callback ( nlex’);
3
lin... Hast (Second); || output: Alex
| Second Function that is passed as an argument
inside inst function is called à callbèck
Junction. _
= (notes The callback function is helpgul then
you. have to wait. for a seault thot
takes time. =
3 — Jens -
| <toneso DION of unique values _
No_index-hased access
| A antd——
_ [sets one itenable — de
seta have its mon methods.
let items = new set);
a rT
ee Se oe i
Any un eta 2
ad
Object
Can—hawe. dect values nenn Beta
Cannot. pela
«Th Bil la “padined by tnd Whereas
—tilssets tOhnnot oo ais à. 1