What the heck is the event loop anyway? | Philip Roberts | JSConf EU

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 1,8 тис.

  • @sumanyusoniwal5194
    @sumanyusoniwal5194 7 місяців тому +425

    9 years later, and this is still pure gold.

    • @vitvitvitvitvitvitvitvit
      @vitvitvitvitvitvitvitvit 6 місяців тому +8

      yeah, but now there are microTask queue too, which one is prioritized and execute the callbacks before task queue

    • @nomadshiba
      @nomadshiba 5 місяців тому

      @@vitvitvitvitvitvitvitvit we also have WebWorker(s) too

    • @patelmilind7621
      @patelmilind7621 4 місяці тому

      @@vitvitvitvitvitvitvitvit you got answer to this??

  • @apoorvasa1026
    @apoorvasa1026 2 роки тому +1512

    Today I had interview and was asked about execution context and i explained him based on this video. my interviewer was so impressed with the my answer. he said "This is the best explanation i have heard so far". made my day 🙂

  • @marios2liquid
    @marios2liquid 10 років тому +4191

    This talk is the perfect example of "If you can't explain it simply, you don't understand it well enough". Well done Philip.

    • @MehdiRaash
      @MehdiRaash 5 років тому +14

      That's quit simple!

    • @JennHayden
      @JennHayden 5 років тому +4

      agreed

    • @gopalgplus
      @gopalgplus 5 років тому +2

      Agreed!

    • @pastuh
      @pastuh 4 роки тому +11

      CS50 teacher explains very well too.. Sometimes i'm worried he will forget to breath..

    • @seongamkim4834
      @seongamkim4834 4 роки тому

      That sounds wonderful.

  • @syedmuhammadibtisam441
    @syedmuhammadibtisam441 Рік тому +576

    He understood it in 18 months, for me it took 26 minutes, that is how much he helped me, really appreciate it. Time is all you have. Thank you man!!!

  • @sunmustbedestroyed
    @sunmustbedestroyed 9 років тому +1470

    I like this guy. He's so humble and explains things with such clarity - an for a universal audience. That's no easy feat.

  • @BURN-ADDiCT
    @BURN-ADDiCT 2 роки тому +28

    "I did not do a computer science degree, so these words... they're words"
    I relate so so deeply with that

  • @R3fuge
    @R3fuge 2 роки тому +104

    8 years ago and this is still my favorite explanation of the event loop. Brilliant communication.

  • @luciferonetwothree2030
    @luciferonetwothree2030 5 років тому +1434

    watching this in 2019, and it is still the best source to learn JS event loop.

    • @bennyrussell4966
      @bennyrussell4966 5 років тому +11

      couldn't agree more, just rewatched it there for a refresh

    • @castelocl
      @castelocl 4 роки тому +32

      watching this in 2020

    • @petrd6173
      @petrd6173 4 роки тому +4

      @@castelocl and still relevant!

    • @360-sreet-view
      @360-sreet-view 4 роки тому +7

      still the best in 2020

    • @yuanmin6496
      @yuanmin6496 4 роки тому

      @@360-sreet-view I agree

  • @c3eb4
    @c3eb4 5 років тому +251

    i can't even express how much i appreciate this video. i watch it every couple of months as a refresher. and encourage my team to do the same.

  • @AndreOliveira-vq7iv
    @AndreOliveira-vq7iv 5 років тому +449

    13:45
    "The event loop job is to look at the stack and look at the task queue. If the stack is empty, it takes the first thing on the queue and pushed it on to the stack."

    • @mementomori8856
      @mementomori8856 4 роки тому +1

      what if there's multiple tasks in the queue ... and they'll get done in some order ... doesn't that make it a sync-function of it's world??

    • @mementomori8856
      @mementomori8856 4 роки тому +1

      never mind ...

    • @khaledelnagar4135
      @khaledelnagar4135 3 роки тому +52

      @@mementomori8856 it's async for you as a developer, but at the end, there has to be a queue for that poor single thread... serverless is serverless for you but at the end there has to be a server to run your code!

    • @viridianite
      @viridianite 2 роки тому

      @@khaledelnagar4135 This makes no sense

    • @kaelon9170
      @kaelon9170 2 роки тому +4

      @@viridianite It does make sense, but only if you have some basic working knowledge or better on how multithreading works, and the fact that JS is still a single-threaded language despite supporting asynchronous code.

  • @Hariharan-sh6bo
    @Hariharan-sh6bo 9 місяців тому +4

    Graduated in 2015, worked in JS alone for 4+ years, discovered this only today! Thank you

  • @element3663
    @element3663 3 роки тому +61

    This gave me a breakthrough moment in realizing how async JS actually works. Really good talk.

  • @domaincontroller
    @domaincontroller 3 роки тому +368

    00:53 how does javascript actually work ? 02:46 V8, setTimeout 04:03 the call tack 07:18 blocking, what happens when things are slow 10:35 aynchronous callbacks, setTimout 11:13 aynchronous callbacks, the call stack 11:56 concurrency 12:50 stack, webapis, eventloop, task queue, console

    • @FoysalAhmed-gd9sp
      @FoysalAhmed-gd9sp Рік тому +28

      00:53 how does javascript actually work ?
      02:46 V8, setTimeout
      04:03 the call stack
      07:18 blocking, what happens when things are slow
      10:35 aynchronous callbacks, setTimout
      11:13 aynchronous callbacks, the call stack
      11:56 concurrency
      12:50 stack, webapis, eventloop, task queue, console

  • @manasgupta_xyz
    @manasgupta_xyz 7 років тому +75

    This guy just cleared the stack for my callback queue of understanding javascript to execute.
    Great explanation.

    • @Nadrioc
      @Nadrioc 4 роки тому

      @@xxicenturyfuck1195 He mentions he used Keynote, which is the powerpoint for Apple software. There a ton of tutorials online showing how to do animations

  • @braunbaerhh
    @braunbaerhh 3 роки тому +2

    7 years later some things have changed. Now we have service workers in a seperate thread. And we have await/async functions. But yes, this talk makes the things clearer to understand. thank you!

  • @AshokDey
    @AshokDey 7 років тому +35

    It's the first time I'm giving a comment in 7 years. This guy did such a great presentation. It was fantastic. Such a complex topic broken down into small lucid chunks ! Great work.

    • @Martinit0
      @Martinit0 2 роки тому +6

      Puh, hey I'm your callback. Why did you queue me with 5 years delay?

  • @guilhermeferreirabr
    @guilhermeferreirabr 3 роки тому +4

    Funny how many "senior" JS devs think that they are clever AF because they interview you with this kind of questions but, in here, he managed to explain so clearly these concepts that destroy all the "mystery" of these guys intelligence ...
    What an awesome explanation! Simple and sharp!

  • @hraynaud
    @hraynaud 8 років тому +25

    This is by far one of the best presentations on any programming concept I've ever seen. Absolutely brilliant. Thank you!!

  • @ichiroutakashima4503
    @ichiroutakashima4503 Рік тому

    You know this is the best video when content creators link this video and call it as the "best explanation for event loops".

  • @jonsanders2069
    @jonsanders2069 6 років тому +23

    I've returned to this video several times to engrain the concept of the event loop in my head. It's so clearly explained and so useful. Thanks so much for making it!

  • @Middollo
    @Middollo Рік тому +1

    I find myself coming back to this talk as i progress in my career as a JS developer. I think this is my third time watching it, it gets better every time. Well done.

  • @ClaymorePT
    @ClaymorePT 7 років тому +37

    From someone who does not have a degree in computer science, I have to say, this is one hell of a good explanation!
    I only which that the teachers that I had during my CS degree, explained things as good as this guy.
    Really awesome!

  • @aminukano_
    @aminukano_ 5 років тому +1

    I just pause while watching to recheck the speaker's name, wondering that we still have such great speakers.
    This is by far the best tech conference talk I ever watched in my life!!

  • @MelMacaluso
    @MelMacaluso 5 років тому +10

    Genius talk, seriously. Not hiding behind many fancy technicalities and being able to still convey high-level concepts and make them understandable is surely not an easy skill. Props!

  • @kikevanegazz325
    @kikevanegazz325 Рік тому +1

    There are really no words to say how great this talk was. Amazingly clear, fun, and straight to the point.

  • @chunk1978
    @chunk1978 5 років тому +5

    This is by far the most informative and accessible talks about asynchronous functionality in JavaScript. Thanks, Philip, for showing us the light.

  • @nathancovey
    @nathancovey 21 день тому +1

    Came here from the Odin Project. This video is gold

  • @maximpekarsky7266
    @maximpekarsky7266 3 роки тому +5

    This was my introduction to great conference talks, and, I really believe, one of the experiences that turned me from hobbyist to developer.

  • @mdmobasshir595
    @mdmobasshir595 Рік тому +1

    8 years down the lane for this video, current in year 2023. Buffering through many videos on event loop still find this one the best. The energy of this man...can feel it on screen as well. Wish i could attend his session once in my life in person.

  • @prashantchauhan1360
    @prashantchauhan1360 2 роки тому +3

    One of the best js videos till today. I wonder it was uploaded 8 years ago. If i would have watched then I would be that much AOT (Ahead of time).

  • @plsrematch4071
    @plsrematch4071 Рік тому

    Just came from Theo t3. I’m a web dev fresh out of college with about 5 months full time experience. This was awesome. Still teaching us almost 10 years later!!

  • @carlellis9647
    @carlellis9647 4 роки тому +5

    This is one of the best lectures on JavaScript that I've seen anywhere. Phillip does a great job of using visualization to explain some of the more complicated aspects of JavaScript programming while making it look easy. That's truly commendable.

  • @parveznawaz99
    @parveznawaz99 8 місяців тому

    Philip describes the event loop mechanism in a perfect way. Lots of love and respect.

  • @thedevcyclist
    @thedevcyclist 8 років тому +605

    Best event-loop explanation ever .... !!!

    • @johannbauer2863
      @johannbauer2863 5 років тому +5

      What about Jake Archibalds explanation?

  • @inordirectional
    @inordirectional 3 роки тому +7

    I've been watching some interviews and mocks preparing for my own, and people nebulously reference 'the event loop' and single-threadedness very often, like "How does X work?" "ahh, the event loop", but more in a buzzword way than as an explanation, so thank you for this video. It was super helpful

  • @idrisawedazubair2562
    @idrisawedazubair2562 Рік тому +1

    I've literally read many articles trying to understand this very well, but now I think I do. His explanation is amazing.

  • @DecaSpace
    @DecaSpace 8 років тому +24

    The intro music tho.... I turned off the lights and got my glowstick game on. He's amazing. It was an excellent video. My ADHD did not kicked in ever while watching it. 10/10. Will buy again.

  • @xtraglitch
    @xtraglitch Рік тому +1

    2 mins into the video i thought let me skip this but then i watched it fully and now i am glad that i did

  • @nadiar.syaripul
    @nadiar.syaripul 8 років тому +844

    this video changed my life,.. great

    • @babas_babas
      @babas_babas 8 років тому

      +Nadiar AS Same, his show is really clear, I learned so much thanks to him :p

    • @jonnieve2483
      @jonnieve2483 8 років тому +1

      Yeah, awesome presentation

    • @lakshithaweerakkody5326
      @lakshithaweerakkody5326 6 років тому +1

      Truly is. Mine too. Simply Brilliant Video

    • @aishahale5504
      @aishahale5504 5 років тому +5

      You need to know about Tony Alecia

    • @Gigusx
      @Gigusx 5 років тому

      lol.

  • @Mona001-01g
    @Mona001-01g 5 років тому

    Finally it took a non-science graduate to explain this to me! Bravo Philip. God Bless u. Struggling with this simple thing for sooooo long!

  • @rameshwari
    @rameshwari 4 роки тому +40

    Wow... amazing lecture. The way he is explaining is great. I wish a whole JS course should be taught by him.

  • @dcascato
    @dcascato 3 роки тому

    The reason why this video is so awesome for many people, is cause he really had the doubts a truly beginner has.

  • @JoseSotoCanHelp
    @JoseSotoCanHelp 10 років тому +10

    When I watched this video, I knew it would prove useful for my work. Less than a month later, it happened. Thank you for the great presentation!!

  • @cronus663
    @cronus663 2 роки тому

    I remember I watched it back in 2016, and now in 2022, I came back to check if it was as good as I remember, and... yes, it's definitively is. There's a real good stuff here, congrats Philip!

  • @okikiolaosunronbi8766
    @okikiolaosunronbi8766 Рік тому +3

    This has to be one of the best explanations out there about the event loop.

  • @bharghavak
    @bharghavak 2 роки тому

    Some explanations are so good that you understand the concept crystal clear. It really sticks with you, thank you.

  • @manojmj5479
    @manojmj5479 6 років тому +15

    This video is life-changing! Thank you for this, Philip! It takes great understanding to explain complex things in simple ways. And thank you for not gatekeeping - we need more people to come into tech and videos like this make sure that even noobs understand and can work with seemingly hard concepts!

  • @OwenMcKenna
    @OwenMcKenna 6 місяців тому +1

    His tool, Loupe, which he introduces here, visualises the JS runtime at run time. 🌟 Just brilliant. 🌟
    I wish I had seen this demo 10 years ago.

  • @johnnychan6755
    @johnnychan6755 9 років тому +15

    I have been trying very hard understanding this whole JavaScript event-loop, callback, and asynchronous concepts for WEEKS (and failed), despite tons of google searches, article readings and tutorials. I think I finally "got it" after watching this video. So thank you SO MUCH for the talk Philip!!! (and thanks for sharing this JSConf!). I sense "hope"... in understanding and using JavaScripts :)

  • @Combine1331
    @Combine1331 5 років тому +1

    Great teachers are like Phillip Roberts - explaining as simple as that. Thank you, Phillip! You brought hope to my life!

  • @navaneethagastya
    @navaneethagastya 10 років тому +27

    Really, Amazing talk, bro! :)
    Once I came up across a scenario where calling a function, say "func()" did not work rather, setTimeout(func, 0) worked!
    Now, I understood the reason completely!! :)

  • @marcosrausch1887
    @marcosrausch1887 4 роки тому

    I wouldn't be able to say how much of a help this explanation has been to my JavaScript understanding.
    Of course, I know now that might be 'cause the callback in charge to say such thing is waiting for the stack pile to be empty.

  • @nosajghoul
    @nosajghoul 9 років тому +123

    @19:18 you can see his history. I found it reassuring that a guy with this level of knowledge still has to look up the syntax for Date(). :-) Great dissection of the event loop.

    • @timeslowingdown
      @timeslowingdown 6 років тому +65

      Good example of why code interviews that just test how well someone has memorized various language apis/functions are an ineffective way to determine the candidate's knowledge :)

    • @lighterinthestorm
      @lighterinthestorm 5 років тому +2

      @@timeslowingdown None of those tests actually check if you have those things memorized. All those tests are there to see how you look for the best available solution

    • @timeslowingdown
      @timeslowingdown 5 років тому +9

      @@lighterinthestorm Finding the solution to a single function with input and output is very different than writing an entire application or maintaining it, so I beg to differ

    • @kotekutalia
      @kotekutalia 4 роки тому +2

      That's why Incognito Mode exists

    • @theshermantanker7043
      @theshermantanker7043 4 роки тому +3

      Remembering the correct parameters for a function in a library is not a prerequisite for being a good developer, in the same way that needing a calculator in a math exam doesn't mean you're cheating. If you like calculating or memorising sure go ahead, but if you're lazy it's fine

  • @CedevismoLiberale
    @CedevismoLiberale 4 роки тому +2

    This is better than anything any professor have ever done to explain anything to me in university.

  • @sushilkumartechy
    @sushilkumartechy 7 років тому +116

    thanks @Philip Roberts first time I completely understand event loop :). If you have some other video on js please share.

    • @aishahale5504
      @aishahale5504 5 років тому +4

      Javascript Understanding the weird parts

    • @NishadAhsan
      @NishadAhsan 5 років тому

      @@aishahale5504 Different author.

    • @aishahale5504
      @aishahale5504 5 років тому

      @@NishadAhsan Yes, try it.

  • @rt-uh6mt
    @rt-uh6mt 2 роки тому

    OK, I just finished watching this 20 times in a row and now, I finally have it fully memorized. Can't wait to recite it all to my next interviewer.

  • @thesuperiorman8342
    @thesuperiorman8342 3 роки тому

    I'm watching this in 2021. I overlooked this video because it's old. Well I came back because I was disappointed with all the other more recent videos I watched. The speaker here did an excellent job at simplifying the topic. I'm so glad I watched this. I just hope it is still very relevant today. I can't imagine much has changed.

  • @shalizi1280
    @shalizi1280 8 років тому +30

    This is absolutely a marvelous explanation of event loops within javascript. It doesn't get better than this, thank you.

    • @yeshiqing8929
      @yeshiqing8929 7 років тому

      Do you know what the ppt is made by? I like the ppt style(animation most). but i think the microsoft ppt is so heavy

    • @4Y0P
      @4Y0P 5 років тому

      Ye Shiqing its made in keynote

  • @v4raziel
    @v4raziel 4 роки тому

    Thank you phillips. i been programming from 12-14 years. never come i across to understand event loop. thank you so simply explained.

  • @andriciandu
    @andriciandu 5 років тому +304

    For videos like this, youtube should implement a multi-thumbs-up system.

    • @RockDavid
      @RockDavid 5 років тому +5

      They already do, how else you think Fake news is so "Popular" these days

    • @coldblackice
      @coldblackice 3 роки тому +1

      @@RockDavid I think you misunderstood what he was meaning.

    • @sarthaktyagi0447
      @sarthaktyagi0447 5 місяців тому

      @@coldblackice I think you misunderstood what he was meaning.

    • @sheepcommander_
      @sheepcommander_ 4 місяці тому

      @@RockDavid ?????????

  • @MrLiudongtony
    @MrLiudongtony 4 роки тому +8

    Watched it at the end of year 2020 and it is still one of the best in its kind to explain the event loop.

  • @aniruddhadas3606
    @aniruddhadas3606 2 роки тому

    This probably the best explanation in layman terms I've seen on any tech related videos.

  • @sethfeingold
    @sethfeingold 5 років тому +5

    This will no doubt remain a fantastic presentation well into 2020 and beyond. Thank you, Philip!

  • @baldEagle_
    @baldEagle_ 4 роки тому

    i show this video to my GrandMother ...
    now she understands what Event Loop is..
    what good explanation.

  • @CodeSynergy
    @CodeSynergy Рік тому +3

    oh, that was in 2014 and I thought it is the latest talk, amazing!

  • @sayori3939
    @sayori3939 2 місяці тому +1

    those last examples were really mind blowing

  • @Мажорвчате
    @Мажорвчате 3 роки тому +3

    Рассказ, понятней чем этот мне ни разу не встречались. Спасибо большое за видео и за перевод

  • @ismoilshokirov
    @ismoilshokirov 2 роки тому

    8 years have passed, but this explanation seems to me the best on youtube

  • @kwstasl2
    @kwstasl2 9 років тому +7

    Great explanation! Just one note: at 23:35 , lines 12 and 13, I think it should instead be
    array.forEach(function (i) {
    setTimeout(cb, 0, i);
    or else the array element will not be passed to the callback and console.log() will log them as 'undefined'.

  • @prashantchauhan6591
    @prashantchauhan6591 2 роки тому +1

    watching this in 2022 and still one of the best resource to learn JS event loop.

  • @Josematube
    @Josematube 8 років тому +239

    Great explanation.

  • @msbecks3806
    @msbecks3806 3 роки тому +1

    Honestly, your explanation is down-to-earth for the understanding of
    all. Great work!

  • @agusmoles
    @agusmoles 5 років тому +26

    2019 and this is still awesome. Great explanation!

  • @mdirshath4174
    @mdirshath4174 3 роки тому

    Man, I wish I got a teacher like him. First time I understood how JS works. Legend.

  • @TheHolyReality
    @TheHolyReality 8 років тому +166

    Interesting how no textbooks mention this stuff wich in my opinion is crucial in understanding core javascript and especially closures (especially when every example on closures out there contains *for* loop with setTimeout and never explains or even mentions event loop and why does *for* loop first finish its iterations and then invokes setTimeout callbacks)

    • @ihateslowcars
      @ihateslowcars 7 років тому +7

      I just made the connection with what you're saying! It finally makes sense!

    • @johnb1391
      @johnb1391 7 років тому +28

      What he means is that a very common practice question given to novices to see if they understand closures is the following:
      const arr = [0,1,2,3];
      for (var i = 0; i < arr.length; i++) {
      setTimeout(function() {
      console.log('index ' + i + ', value: ' + arr[i]);
      }, 3000);
      }
      //Prints 'index 4, value: undefined'
      The issue here is that because var is function scoped and not block scoped, i will break out of the loop when it hits the value 4 (as i will now equal arr.length, breaking the test of the for loop). As index 4 is out-of-bounds, it returns undefined as the value for arr[4]. Closures via something like the let keyword mitigate this problem, however. So the test in question is to see whether or not the novice understands the issues of closure with var versus the new block-level variable definers: let and const.

    • @raulnoheagoodness
      @raulnoheagoodness 6 років тому +2

      Javascript: The Good Parts by Doug Crockford explains closures very well. Also function-orientation. Other core JS lang features, but not the event loop.

    • @chriscorrigan14
      @chriscorrigan14 5 років тому +12

      @@johnb1391 Or maybe a less granular way to explain it is: once the for loop is done setting up the setTimeout callbacks, it is finished, and the variable is at its final value of 4. Meanwhile the callbacks run for 3 seconds each, and they are still active - when they print the value of i, it is always 4 (unexpected). You can create closures around the timeout function value to keep the value of i as it was when the callback was created, by either passing it to a function outside of the loop to create the callback, or just making that setTimeout function an IIFE - immediately invoking it creates the closure while the i is still at its iterative value.
      Well I guess that was more words lol. Is there any simple way to explain closures?

    • @boliussa
      @boliussa 5 років тому

      @@chriscorrigan14 thanks that's a great explanation,, can you include some code examples for "You can create closures around the timeout function value to keep the value of i as it was when the callback was created, by either passing it to a function outside of the loop to create the callback, or just making that setTimeout function an IIFE "?

  • @ighsight
    @ighsight 2 роки тому

    Brilliant. No question that this talk opened up new doors for this young man.

  • @JoshuaDellay
    @JoshuaDellay 10 років тому +6

    Talk about boss mode, great work by Philip! The loop tool he created is amazing for helping to visualize the runtime, event queue/loop and web api! I can only imagine the time that went into creating and researching how to build it and you can see by his facial expression how much of a challenge it must have been hahah!

  • @justadev____7232
    @justadev____7232 4 роки тому +1

    Mind blown!!!!! The lightbulb just turned on. THANK YOU!!!!!!

  • @djkater
    @djkater 8 років тому +797

    the gareth bale of js!

  • @zackisser2451
    @zackisser2451 4 роки тому +1

    No matter how awesome and great a video is you'll always find dislikes ... Who are you people ? What was the reason to dislike this ?

  • @DeepakSingh-uf5vv
    @DeepakSingh-uf5vv 3 роки тому

    this should be the first lecture for anyone who is trying to learn js, as it shows what's happening at ground 0.

  • @mohammedelhadididi4612
    @mohammedelhadididi4612 3 роки тому +3

    This lecture is just a masterpiece

  • @zahinhasan3748
    @zahinhasan3748 3 роки тому

    Honestly, I watched it last night while sleeping but the way my guy explained was so good that I am still thinking about the diagrams he showed this morning!

  • @kevinbuffington4008
    @kevinbuffington4008 2 роки тому +1

    I randomly watched this video a week or two before I went on a job interview five years ago. The event loop came up in some advanced JS discussion and I'm convinced it's a big part of why I got the job. Got another interview coming up and I figured I should probably revisit this just to make sure I still remember it. Still just as informative as I recall.

  • @syedbaryalay5849
    @syedbaryalay5849 5 років тому +4

    worth every second, watching it the second time.

  • @perfect.stealth
    @perfect.stealth 3 роки тому

    I never understood what the stack and the queue was until i saw this video.
    Knowing what's happening in ghe background is important, and will help us become better developers.
    Thank you sir.

  • @rahulraut1569
    @rahulraut1569 5 років тому +5

    This video has helped me cracking interviews!! Thanks Man!

  • @kerompo25
    @kerompo25 9 місяців тому

    One of the best videos on event loop I've seen. The examples, animations of queue and stack are very clear and I've got almost everything, although I'm just starting to learn async functions in JavaScript
    Thank you for this great explanation!

  • @AlexGitonga
    @AlexGitonga 9 років тому +7

    this guy said he no computer science guy! can't believe it with such explanations thanks alot

  • @azur3125
    @azur3125 9 місяців тому

    This might be one of the best lectures/presentations I have ever seen. So clear and makes the topic easy to understand. Fabulous work!

  • @juanmanueltoni2506
    @juanmanueltoni2506 10 років тому +7

    Amazing,!! the best and simplest explanation I've seen, thanks

  • @blakesim7827
    @blakesim7827 2 роки тому

    god I watched this video a year ago and now finally understood how it works. that loop simulation really helped.

  • @sahilattri51
    @sahilattri51 8 років тому +8

    brilliance! Absolutely stunning. Thank you

  • @yogeshdharya3857
    @yogeshdharya3857 2 роки тому

    Watching this video in 2022 , still a great source for some one who willing to understand asynchronous behavior in JS .

  • @AnimatedV
    @AnimatedV 7 років тому +9

    So no one bothered to ask if JS is single-threaded, how can it also, in parallel, maintain an event-loop. The event-loop is actually provided by the browser.

  • @greenbeleleghasim6893
    @greenbeleleghasim6893 Рік тому

    This is how to do a video tutorial in technical topics. Splendid animations that make you part of the "journey"

  • @BernardoLeon
    @BernardoLeon 8 років тому +36

    The timeout is executed in the WebAPI right? What does that means? WebAPI executes in another thread? or why the code running in the Web API (section?) does not block the unique Thread JS has or does JS have other threads in the background?

    • @BernardoLeon
      @BernardoLeon 8 років тому +1

      Federico Rodriguez The most upvoted answer here will throw some light. qr.ae/ROfg32

    • @polyglotdev
      @polyglotdev 8 років тому +20

      +Bernardo Leon Yup there is a dedicated thread for the event loop and a bunch of threads in a thread pool to handle the callbacks. The thread pool is transparent and is not meant to be accessible from any JS constructs. However as of lately we have Web Worker thread pool progammatically accessible to JS to offload long running CPU and I/O intensive work to a different background thread pool.

    • @BernardoLeon
      @BernardoLeon 8 років тому +1

      Thank you *****

    • @TheBohrabohrafamily
      @TheBohrabohrafamily 6 років тому +33

      Trying to answer all your questions
      The timeout is executed in the WebAPI right? - Correct
      What does that means? - It means the *timeout* code is running as part of a different part of the Browser process (Chrome, Firefox). It is *NOT* running within the Javascript section
      WebAPI executes in another thread? - It runs in a different area of the browser process and it able to run concurrently with the code that is running on the Javascript side
      or why the code running in the Web API (section?) does not block the unique Thread JS has or does JS have other threads in the background? - The browser is able to run multiple things (the WebAPI, the event loop, the rendering engine and the Javascript processor to list a few) concurrent. But the JS processor does *NOT* have other threads in the background, in its limited view it can only do one thing at a time which is defined as what's one the top of the call stack

    • @philtrem
      @philtrem 5 років тому +1

      ​@@TheBohrabohrafamily Thanks, I was suspecting that the "it runs in another thread" explanation was incorrect. n.b: The distinction between concurrency and parallelism is an important one.

  • @Samuel-wi1dh
    @Samuel-wi1dh 4 роки тому +1

    Still watching this in 2020 and has made JS clearly than anything, and the joke at ~ 17:30 was great to see. Shows personality and gives an almost Steve Jobs feel. Top draw.

  • @rubenfranco7690
    @rubenfranco7690 5 років тому +9

    Omg when did Gareth Bale started to code, this is amazing

  • @gnclmorais
    @gnclmorais 9 років тому +6

    Excellent presentation! 👏👏👏