s
-props and method Date
Var a Page
name "kiran",
class : BTech,
number: 123
tasks : funcion()3 metbed
Lohen a value ot a proper is q functfan, then tis
method
a. narne Mes"
upddtng
Ấvanced
s
dlerence beth var,
et let, Const
Js .. ES5 + ES6 = var, let,Const
ESS ESG
4 Var let
Const
var old is me hai ) let, const neuo js me hai
2) yar is Punchion scaped i)let, const are braces
sCoped.
Function abcd)|
For (var i=o; i<1o, j4) Por(let i=o; iK10; it+)
3
Console.logi), asgale.lg);
Console. Iog(i); -acesible
hot acesstble
var is qccessed qll over the tun,
3)Var adds tsel to HỘ let,canst.dont add.
Loindow object. to windoo obfet.
Page
4indo ohiect
Js langug me kai sare aaise teturos hai, jo
hum Use Karte hai ,par vd S me nabi hai
Js vo sare eaturels oindus oiect se leti hai
→ Windoo is a box o teatures
Super
windouo
alert, prompt are proy} oled
brou) ser.
-- brouser Cotet ApI
Ls Stack
Ly heap ab.c,d
texecured
|+2+3t we
direc Com pue this , b
hous Conputer does
1+2 =3 -→sto3 ohere, a,6 ate stored dring
3+2 6 the execution ?
6+4 lo → prnt in heap memrA
xecution Cotext clASSMAte
when ever a tunchon is called, Hs
Date
Page
exerution conext is create d which stores
the vaiables|Functians andlexical envinsomet.
functton abcd ()
exec. Cortr abc
Yar a = 1D,
Function hello () Vanab funen
Nar b he llo)
lextca
t tells who Can access what?
fun abcd has access
to Var 4 hello ()
a function scape is
burt, it Cant access var b 4he reassn.
mSopg}efence values
taq. Var a - Li,2,3,4]
b=
Var a wrong
*using spead operstor.
Yar b = L... a] → this is bao it is done
Var obi1 name
Yar
-truty vs fal Dote
Hud to iderttytal? Page
o, False, undeineo), Na, hul), document. al
all the valuesother than his are
4CHaN)
3
ese
exerted
for Each
→ only applied on artas
Var a = This Funcon run's tur
Nal eve elenet og arrag
a. torEach(Functton Fun cion (val)
3)
This heNer update's AnonmoS
Punion
4he original arrq Le, wthot name..
-- for in
only applied on okjects
Var a
for (var key in a)
name Kiran",
4ge 29 Consale. lo (); -→ accessin
k y
i al keyJvalue
callback function's→ Asgnc Part o ,classmAte
→ this is a funton ushich run's atter Date
sometime, atter tiniohing Some task
. setTimeout Function ()4this tuncin run's
console.log (rr Callback); atter 2 seconds.
2060 ); |660 s=1 Sec
First class Funcons
Can treat he tuntions as a Yaria ble
yar a = Function c{
Cansl e. logl" Meous';
olp: Meow
u Can pass Funn to fnc
Punction abcd (a)
a)
abcd ( Function ( ) Console.log (" Hella")):
hoo arroH's Credtecd behind the scene
evegthing object in js
name
t
Nar a -[i, 2, 15] delete a.ge properg
type o/p 'abject
21S
LI, 12, 1s
-3-2-|
ngthive tndices
a2 l2 -2:2
--biher order Puncson alAssmte
sH is the funetion which acepts ansther
Date
Page
fun ction as an arqumert
retun's a funchion.
function abed()
return funchion(>
Constuctar funchon
→H is the pe o ngtmal funcon in which this)koooe
is used g while calling thed uneton Oe use jnew 19
price
funtion make&iseuit c
4his, width = 10 +his price price:
+his.height - l6;
+his, c\or = er Broop":
Sugarg"
Var Bisl = bew makeBiscut(); od Can have
Bis2 Instancels
mary
Can ql So pass pa rameers
hoard
→t alcgs createls a blank oķiect
ife immediately invoked fun cion expression.JASSMAte
H is the oay to run a tuncion imme diate
anol create private vaiable instde t
(Funchon(o
Var a =12;
)O
when ortte this, t becs els iite
Console.log(a) → nst accessible..
on acce ssible wthìn the func,
you Can return H. t t retun cbi & stre în vari
. var ans = C fun cion ()I
return 4 )0sn
deine methods in reurnd
. accessig 2. Setting value
qetter : function( ) 4 setter: function(va)
Consale.lpg(a);
Var ans = ( Funchion ( ) 4
Var
return
aetter; Funchon)
(
console. lsg a);
Setter: Puncion(va)t
a= val;ie
--Pntetgee clAscMAte
e
Var got bnuoser,consol
name:Kiran"; tpe ohi
here, oill be name' în
bet also tt pratutypej)}d0
→0e dor't create t then ? t aomes oth eve obje
g ct
S provi ded by javas cript.
Exqmples i ar. length
prototypial inhettance
acce ssing propertes o ansther class.) Funchiandbied
eg there are humans sho can do several tasks but
also there are sheriyan's students oho Can do some
t their oon tasks plus al) +he tasks t human.
Var human =
Can Talk : true,
Can Aal k;true, Girenshihk
CanPy : false
Var
sheriyanStudent
create Awe Some lebs : true
crete ALoarded ebs: true
sheriyan Shudent. Proto = human;
Contains all prps buman,
sheriganStudent, can Talk;
this Ke9d clssMAte
0 in globa scop
e Date
Page
console.log(this):
Ly wingous
in g fun hon G event listener
Fun cion ábcd () var btn = documert.
con cole. ləga (this): btn.add Event Listener
", FunctionC)
arsule lg(this);
@ inside a method
elemerct
yar obj ={
name; " Mes
getter funcionc{
Con sale.l og +this)
objet.
call, appbind
it you hae d tunchion and a object. & Hou uoant to
run that Funchon burt aso ou uOan thet the
by detautt value ot this o be changed to object
then e
appy thee nethods.
alFunchon abcdc ) this, name
Gonsle. logCthis); 3 deautt behavior is nsuw chagrd
Var obi=name;meow'"
abc d.call ( oki)i
#ape when gou oant to send mutiple vakelsclASSMAte
Loith obj Date
Page
Funchson(val,yal2, val3)
Console. log (this, vall,val2., );
Var obj = namekiran"})
abcd.a call ( obj, 1,2,3); > X oong
abcd, apply(ohi, I',2,31) → Gorect
#bind
var bind fun = abcd.bin (cbi)
bind Pun ();
when Hou oant to run H in
tuture..
eg. evemt listeners
pure Funchons
1.+ should aloas retutn eame ourtput tor
2. H oil) never în
Same
change the value ot glsbaľ variable.
gut
fun chion abcd (a, b)
return axb;
Var ansL = abcd(I,2):
Var ans 2 = abcd (, 2);
→ inpure Function's are
haring opposte be hayiot.