Understanding the LIFO/FIFO nature of the call stack vs the event stack is really cool, thank you.
@JamesQQuick2 жыл бұрын
So glad that was helpful :)
@goyii11 ай бұрын
This is true but i think its important to not call event queue "stack" when the real data structure its a Queue. When you think about stacks and queues from real life everything makes sense
@Shagidelic4 ай бұрын
you mean event queue, not stack. Call Stack -- is stack, event queue - is queue.
@thanhattran284 Жыл бұрын
Finally, after looking for n^1000 videos, forums... I found a person who can explain these terms in real simple and understandable way 😭really appreciate your work man.
@rafadydkiemmacha75438 ай бұрын
Really? It was a very lame explanation. He skipped many essential parts while dragging on single things.
@Mo-Sam2 жыл бұрын
I loved it, thank you. It would be so great if you make a series like this , explaining advanced concepts under 5 minutes.
@indraappkey Жыл бұрын
one of the clearest explanation of event loop, thanks James
@JamesQQuick Жыл бұрын
Yayyy!!
@igoeast7 ай бұрын
This is the best video that describes Event loop. Thank you so much for your work James!
@JamesQQuick7 ай бұрын
Wow, thank you!!
@georgenonis5967 Жыл бұрын
Amazing video. Whenever I forget how it works I just jump over here and everything is clear again. Thank you mate!
@ming39572 жыл бұрын
Expected a 5 minute video but I got 2 whole extra minutes of James for free! What a deal
@JamesQQuick2 жыл бұрын
Always here to please!
@TerabyteTy3006 ай бұрын
Recently came across your channel and I’ve been learning so much. Thank you for all the work you put in on these!
@erishiraj4 ай бұрын
Brilliant explanation with a clear design flow. Thanks, James!
@ahlembs790 Жыл бұрын
i am really thankful for this video just before my interview, , feel having clear idea about what happen behind the scenes with node.js, please more advanced topics like this with such great explanantion
@JamesQQuick Жыл бұрын
Wow, that's so cool to hear. Hope it went well!
@GetGoodatAnything7 ай бұрын
As someone who is new to coding that explanation made the overall process really clarified things for me. Cheers
@umangkathuria709711 ай бұрын
Always come here for a quick refresher before I have to explain it to anyone :) That article is excellent in itself too! great content!
@JamesQQuick11 ай бұрын
Thanks for watching!
@anthonysim5634 ай бұрын
Omg, thank you for this explanation. This was so straightforward and easy to understand.
@NikhilDahriya-o5y6 ай бұрын
Awesome. It was Crisp, Precise, Easy to understand and To the Point.
@kirantechnophile7852Ай бұрын
I watched a tens of videos to understand this. But this video very clear.
@denniszenanywhere2 жыл бұрын
I like this overexplanation. Please do more. I am even watching tiktok videos that loop short coding lessons and they’re sinking in more.
@notarealhandle12310 ай бұрын
I've been developing in JavaScript for over 20 years now. But when I was interviewed recently for a new job, and asked about JavaScript event loop, I could not remember it for the life of me. This is mainly academical knowledge, not something that you need as an experienced developer. People who do interview are often dumb, and do not understand that.
@Microphunktv-jb3kj4 ай бұрын
...this video explains it poorly actually. and you do need to know it.. you're wrong. not knowing event loop and execution context and enviorement and the phases.. is how people fck themsealves with accidental closures and other stuff... most important part to know about event loop is about task queue and microtask queue, how microtask queue has priority, and that web apis.. some of them are callback based, some of them are promise based .. even setTimeout 1000ms for example.. is not 100% guaranteed,that it actually is 1000ms , that's not execution to time.. that's execution to enqueue of microtask queue.
@SammedP-r9s9 ай бұрын
Really nice and simple way of explaining complex concepts. Great video
@manerVlog11 ай бұрын
Awsome sir now I understand watching many videos this is very simple to understand.
@eduardocuadraneyra10 ай бұрын
THNKAS A LOT i was havnig a hard time to get this idea but you have explained really simple, so Here you have a new student, thanks again and have a great day...and if your a reading this and your not the teacher , have a great day to smile, and remember you are important to.
@shuvra03 Жыл бұрын
Best video on node js event loop in 5 minutes
@JamesQQuick Жыл бұрын
AYYYYY!!
@ipa227512 жыл бұрын
Super bro ... u explained a complex theory so simply with a beautiful animation.
@khlgaming365 ай бұрын
Broo you nailed it thank you and thanks to andrew for this informative explanation
@felixurrutia4246 Жыл бұрын
Excellent explanation. This is exactly what I was looking for.
@Karan601917 ай бұрын
Hi , i was trying to wrap my head around the event loop, one suggestion for the video , a brief about v8 + libUv must have been wonderful specially mentioning about the 4 extra threads that libUv brings in so that the fundamentals becomes much more clear, anyways great video as ever :)
@kasiad7291 Жыл бұрын
Perfect explanation, thank you!
@Walocial Жыл бұрын
Awesome explanation, much appreciated. Thanks :)
@marcelukeje351010 ай бұрын
I'm here with no background knowledge on JavaScript. I need to know this for an assignment and I find the video insanely easy to understand
@dpetrik99 Жыл бұрын
Great and short tutorial! Highly recommended
@kai-ninghuang78221 күн бұрын
really well explained, thank you!!
@smachohalla Жыл бұрын
Thanks Mr. Quick. This was neat magnificently explained
@damianodamian79072 жыл бұрын
Now I got it, thank you. That is a really great explanation James! You've got a new sub
@JamesQQuick2 жыл бұрын
Yayyyyy!!! Glad it helped!
@rayenselmen603 Жыл бұрын
Finally ! Amazing explanation Sir !
@abdelrahman1669 Жыл бұрын
really impressive thanks man
@JamesQQuick Жыл бұрын
Glad you enjoyed it!
@ghaithjr.9189 Жыл бұрын
note : libuv is written primarily in c , great explanation king
@JamesQQuick Жыл бұрын
Thanks!
@youngshehata23489 ай бұрын
That was amazing explaining, thank you so much
@Yunraii Жыл бұрын
Thank you very much. It was explained very well and I finally understood what an JS Even Loop is. You did a great job in explaining it!
@JamesQQuick Жыл бұрын
So glad to hear that!
@godswillumukoro89082 жыл бұрын
Great explanation here James!!!
@kostiantynkarzhanov9216 Жыл бұрын
Thank you! Very concise and simple explanation of not an easy concept! 💛
@johnshepard3197 Жыл бұрын
Thanks for the quick refresher, man! Plus correcting my pronunciation of "lib-you-vee" library ;)
@lucascoliveira39572 ай бұрын
Thank you for that content. Keep going
@LucasAlves-si3jb9 ай бұрын
Amazing explanation. Thank you!
@DavyJones124 Жыл бұрын
this explanation was amazing
@ЂорђеЈеленковић2 жыл бұрын
Great video, keep going James! :)
@jean-pierrebanchereau8474 Жыл бұрын
Perfectly explained. Thank you
@koffworld7857 Жыл бұрын
Very clear explanation... great video!
@Rashomon69 Жыл бұрын
Brilliant. I think I finally understand. SUBBED!
@SonAyoD2 жыл бұрын
Wow, I finally get it. Where does the heap come into this?
@tinaxing1020 Жыл бұрын
This is amazing explanation !!! thank you!
@diegogutierrez7032 Жыл бұрын
Something to add there is that. This is the event loop explained from the NodeJS side. If you take a look at the event loop in the browser side. It's much mure complex due to UI taks, Render Tasks, Dom Tasks, Net tasks.
@JamesQQuick Жыл бұрын
I’m not sure that’s true? How is it different? It still uses the same offloading mechanism for async work right?
@muhammad_faraz_ali7 ай бұрын
Great content games🎉. Can you please share which software you used for visualisation?
@mstersierra-xyz5 ай бұрын
thank you for explaining this!
@Kanal5909 Жыл бұрын
For me the most tricky part is that you never really know when the function you call is going to be asynchronous or synchronous. For example if you read data from a file and then process it, for small files it will be synchronous and for the files with let's say 300k lines it will most likely be asynchronous (it also depends on what you do with these lines). It's obvious that all HTTP requests are asynchronous so this is quite easy to handle or predictable at least.
@JamesQQuick Жыл бұрын
Well, I think you can tell something is asynchronous based on two things: 1. it returns a promise or 2. if takes a callback function as a parameter
@elielberra2867 Жыл бұрын
Amazing explanation, it was very clear! Thanks :)
@maxlev621 Жыл бұрын
Best explanation ever
@JamesQQuick Жыл бұрын
Yes! So glad to help!
@utkarshsinghalus3085 Жыл бұрын
wow great video , it simple thanks for the virtual presentation
@EmmanuelIbikunle Жыл бұрын
Very good explanation. Thanks
@JamesQQuick Жыл бұрын
So glad it was helpful!
@hendodesktasks Жыл бұрын
Great Explanation, Thanks a lot
@JamesQQuick Жыл бұрын
Glad it helped!
@asrnyagmur9802 Жыл бұрын
Clearly understand ❤ followed
@DavidLevy-qg7hd9 ай бұрын
nice video but the title is a bit misleading, this is actually the node.js event loop as you say at the end of the video, not the javascript event loop as the title says.. JS natively does not use libuv, instead it uses the browser's built-in Web APIs to handle asynchronous tasks
@xuwu72996 ай бұрын
Good correction
@galnadjar2 ай бұрын
great explanation!
@misterl812910 ай бұрын
Thanks for the video! And yes, I have a question. So we know that every async procedure will go to the event queue. And it will only passed to the call stack if this is empty. So... 1. What about if we have a large large project, with many sync procedures, the event loop will wait until ALL of them finish before pass it to the call stack and give the result? 2. How it work then the "await", if we know that we need to clear the call stack before pass the async functionality. How it work when we need to have some data before proceed with the other instructions? For example data mutation 1, data mutation 2, data mutation 3, await for something() data mutation 4 How it works when we need to have the "something" before go to the data mutation 4 Thank you!
@afridperingaden846 Жыл бұрын
very good explanation
@alexmiserandino1062 Жыл бұрын
fantastic video, thanks!
@Yan-vi6fd Жыл бұрын
Amazing explanation!!
@JamesQQuick Жыл бұрын
So glad you found it helpful!
@alexeecs11 ай бұрын
Great video. One complaint, this is the node event loop which isn't exactly the same thing as JavaScript
@hassanad94 Жыл бұрын
What about js workers? You can do multi threaded tasks with it.
@moneyfr2 жыл бұрын
Getter and setter please and why using it
@JamesQQuick2 жыл бұрын
You're interested in why people use getters and setters?
@ricardocnn2 жыл бұрын
Awesome tips!
@JamesQQuick2 жыл бұрын
Thank you! Glad it was helpful!
@user-wr4yl7tx3w Жыл бұрын
really well explained.
@user-rdr1712 Жыл бұрын
Hi, 5:15 Eventloop use to take the event from queue and pushes into the callstack only when the callstack is empty. Means, eventloop do not take the event from the queue when there is an event(atleast 1) in the callstack. Am I right? What if there are multiple events waiting in event queue. Do the eventloop dequeues all the events one by one from eventqueue when the call stack is empty or it will dequeue only one event?
@dilshodturab2 жыл бұрын
thank you pls do not stop thank you
@RihaLV Жыл бұрын
Great video, thank you!
@ofeyofey Жыл бұрын
He says the event loop is "first in last out" is that out from the place it came it in or other end?
@krnkoravi Жыл бұрын
First time hearing about LIBUV API. I thought async task directly goes from callstack to event queue. LIBUV only applicable in nodejs? Still not clear what exactly processing LIBUV does to async task before it goes to event queue
@dorels6205 Жыл бұрын
Wow, really, really understandable!!!
@reeq5748 Жыл бұрын
U saved me man. Thank you.
@JamesQQuick Жыл бұрын
Yay!!!
@andrewwall27309 ай бұрын
Just a minor correction, libuv is written in C, not C++
@xuwu72996 ай бұрын
Yes exactly
@kacygilbert9434 Жыл бұрын
Thanks for this!!!
@nikman55419 ай бұрын
Okay this is Node platform with C++ wrapper. but what about browser where we dont have Node and still have async JS?
@shashwotbhattarai8731 Жыл бұрын
i don understand the part where the stack is empty and event loop pushes the callback to the stack. will the stack ever be empty? when does the stackbecome empty?
@goyii11 ай бұрын
The stack gets filled once javascript code its readed. Then it will execute functions from the call stack starting from the top, cleaning out functions once executed. In this particular case. The only function added to the call stack was a console.log. But the code also executed an asynchronous function. Wich is sent to the Lubuv Api to ne handled. Once this operation is completed is sent to the event queue. The event loop checks if the call stack is empty and if there is something inside the event queue. If that happens, it will move this callback from the quewe to the call stack. Execute the callback and clean the stack again.
@noorulamin26522 жыл бұрын
Awesome! I have few questions 1. few days ago i was reading a medium article in which they use the term callback queue but here you mentioned event queue. 2 they called it Node APIs and you mentioned Libuv APIs. 3. They also did mention what's called MicroTask Queue, but here it was missing. 4. Does Event Loop handles only Async operations? 5. How does Event Loop handles setTimeout functions?
@JamesQQuick2 жыл бұрын
So I believe "callback queue" would be the same as the "event queue". I would assume Node APIs are also referring to the Libuv APis as well. I have never heard of the MicroTask Queue, so I'm not sure where that fits in. For the event loop, yes, it is only looking for async operations that have finished running. setTimeout takes a callback function. So, when setTimeout is called, it sends it off to the underlying APIs to be handled. When the timeout is done, it then throws the event/callback onto the Event Queue. The Event Loop will find the event on the queue and pass it back to JavaScript call stack. hope that helps!
@ivansandoval37572 жыл бұрын
Same doubt as yours, I just watched a different video where the event loop components are mentioned as follows: Call stack, event loop, micro tasks queue, macro tasks queue and scheduled tasks queue.
@And1997Ruz Жыл бұрын
@@ivansandoval3757 You have probably watched the explanation of the browser event loop, whereas here it's the nodejs event loop They work in a different way. Not to mention the fact that browsers don't have the Libuv API
@andremarrey14202 ай бұрын
You explained very well how it works!! I just don't think you explained why it matters... Maybe another video on that? haha Thanks!
@OpeLeke7 ай бұрын
if it can only do one thing at a time and is mono-threaded, who/what is responsible for executing the background code?
@devonchia59762 жыл бұрын
so if there is an incoming synchronous code and a callback at the same given time, what is the precedence for the call stack?
@AahadCyborg Жыл бұрын
when synchronous code and a callback are both triggered at the same time, the synchronous code takes precedence over the callback function in the call stack. This means that the synchronous code will be executed first, and then the callback function will be added to the call stack and executed once the synchronous code has finished running.
@anushree3744 Жыл бұрын
what does it mean when we say that event loop is blocked and how does that happen?
@mikkun_ Жыл бұрын
so if we have async/await, it will put the asynchronous to libuv, then event queue, and stack it to the call stack along with the other synchronous tasks?
@suryadevarakarthik18146 ай бұрын
how does nodejs handle this code async function doSomething() {} console.log('Hi') await doSomething() console.log('Bye') doSomething is pushed to the libuv?
@mohmmadjesus67102 жыл бұрын
Wonderful Info Sir! please make a series on vue js
@JamesQQuick2 жыл бұрын
Glad you enjoyed it! I still haven’t really spent time with vue yet but I want to!
@TheZeiZei2 жыл бұрын
Great explanation!
@JamesQQuick2 жыл бұрын
Thank you. Hope it helped!
@ctchen198811 ай бұрын
awesome...thank you so much.
@LeLeTesoro Жыл бұрын
Hi there, I'm watching this in April - if I sign up on the website you linked, can I still see the 24 JS and CSS challenges you did for Advent?
@JamesQQuick Жыл бұрын
Yep!
@ghostkee5031 Жыл бұрын
you gonna confuse people between the built in javascript event loop and nodejs thread pool + event loop which libuv provide
@liamdev51452 жыл бұрын
Woa truly appreciate it
@scottweedo6707 Жыл бұрын
Thanks 🙌🏼
@ehtisham_hashmi Жыл бұрын
where I can find more videos on js concepts?
@mkrzyzowski Жыл бұрын
What when call stack is empty and event queue too and some async task is running in libuv thread. How JS know to wait for libuv?
@JamesQQuick Жыл бұрын
Hmm, well JavaScript land just knows to constantly check the event queue when it's done running code. So as it constantly checks, eventually libuv will put something back on the queue for JavaScript to process.