You are on page 1of 8
| TovaSeript_Engine \ J 2s Hey, Sm Tavateript Can you helpme run Okay... So the brocusey Aoseyt t UNNcl exétand Tava Sevipt What ‘it understands is. bits Ci's and o's) Whe can help us heve? Yes\! She Favaseript Engine Shere ave a lok of Javascript Engines out there written by really smart people! For example :- V8 engine 's writen ‘in Cre Ces ‘ney ve prograram eo +0o and col be, Mn adiggrent language) Dkay ,So what's inside tvis eo ret J Se ever heard OF O Memery Lea? A memory heap has imitedk Spa. When you have foo mach Of vn Used mremory tmat you dont free up tne spa gets Filled . No worker, global vorialel are bad CJhey vernon wrought tne execution of | tne code} You must've heared of Skacte over (lous |, Well tnert's ushen Your call Stack overtlows aa t albo hoa Umited Spa fonction Sayttellac) t Conse. lo4 CSimyan SeytHellac) ; W ; ito an int nite recursion and We Vrave Satie Over{low Tava Sevipt is a single threaded language? | Well treat means it has ont | ONE CALL STACK, Ond there pore | ean only Gecute one task | a adme os But Why single twreaded! Hs"quite easy and’ no complica Okay... wait! I¥e heard of Asynchronous prog rarmming , Sf Tavaseript can do tnad, lovo ‘ts it Single +nreaded 9 Let's take an example Set Timeout ( Ly2>$ Consale-loq("cetTime out is asy 41000) , wait Dv a secone SetTimeQut isgiven to vs Web APTs C4rgives Us various RPT se) DH's technically not ® part OF Tavakeyiot . — console-tog C' 4) ® | Seen Ce rE Mane: given by the consele. log ('3"): Wel APL Letra ae crTman [ sexTime out | Send ‘t te web Aer 0 yo | orput 3 Hs (OLA SUS. we. 5 i's prnted wmtne a are out 4 Te setTimeout witn meond 3 - Ortine the scents ae / . are 0 3 Call Sack emery ajter a.seands | | executed Latins pret o ae Leonssi 86D go Jestact 16 new | erngty ancl avt pot ai | ae onsale 4 Welo APT is srl wating | 6) Aitey 2 Seconds are over WEB APLe On its console. leat? daria * treat should be # executed . | This is basically a callback nak IS executed altey Asecs. WEB APT unl send tus bo Callback Queveg Saying theres a callback please proceed. callback | |Callbacea|..-- Callback queve dhis queve basially keeps track oF all callbacks +Hnrat need to be executed. Well nous Hs empty Sole | ever loop unil| take oo colloack gem callbatic. queve and put ik im the oto > pants 2 So Cirally we onsalelosC' 4 a Recap of setTimedut © Pushedto stack, —pG) Passed Jo WEP a & © wait rasa 4 ® Brent Loop eke A dveve emphy and roe Coe

You might also like