Three strategies for the JavaScript event loop - Brain Bytes [Java Brains]
ฝัง
- เผยแพร่เมื่อ 3 ก.ย. 2020
- Learn about 3 strategies you can use in your JavaScript code to work with the event loop and the single application thread in JavaScript
Java Brains website: javabrains.io
#JavaBrains #BrainBytes #HowTo #JavaScript #Tutorial #Concept
"The callback function gets put to the back of event queue". That's so refreshing!
Happy Teachers Day !! One of the best teacher's !!!
Best and the most hidden topic using JavaScript. Great Content
Great .. Can you pls explain the differences between async await, promise and call backs? It confuses all the time..
If we call a function inside another function then it is call called back.
Promises are used to handle call back hells they have 2 parameters resolve, reject. To handle resolve we need to use .then to handle reject we need to use .catch
To handle the promise chaining we will use async/await
We need to use these async/await jointly
for example
async function test(){
let data1=await func1();
let data2=await func2();
}
async > promise > callback
I hope you got some idea now
@@ranikontham5573 Thanks for replying after 2 years tho. Appreciate your effort.
@@CVenture Do you understand it now? lol
There are so many famous tutorials out there that teach wrong things.
Your tutorials are the real thing ♥️.
Please create a complete Javascript course.
You explaine very well...
So well-explained! Thank you!
Happy Teacher's Day Koushik !!. Thanks for your Amazing Content.
As usual you are great in explaining complex things in simple way...
great examples; I learned a lot. Thx!
Best and most simple video so far
Great teacher always simplyfies the explanation like you
Really liked the introduction to web workers. Quality content as always 🙏
Great as usual.I learned a lot of java concept from you now I am learning Javascript advanced staff from you.I am grateful.
Really Awesome, i always recommend ur channel to other people.
Thank you Koushik for this great content
I really like your didactic approach.
Man this is gold!
Thank you so much for such informative video 😊.. Please make playlist of Data structure and Algorithms using Javascript will feel more thankful. Because there is no such playlist to learn Algorithm using Javascript.Thank you 😊
It's Great!!! Thanks a lot . You are amazing...
Thank you so much.
Please create tutorials for Docker and Kubernates, this topic is widely used and new !
Awesome!!! Thanks.
setTimeout(fn, 0) and setNextTick are effectively same right, appendig the function to end of pending function callback queue 🤔. Although for anyone reading there is a setImmediate 😐 which actually happens to place the function call for the next tick and not the end if event loop. 😌 Small nuances of nodejs api
Great explanation, but I have some doubts: In strategy 1, why can't we just call the lessimportantWork() after the moreImportantWork()? why to use setTimeout altogether?
hmm....good question AMC
Js works in a loop. A good candidate would be user interaction and screen update functions. Not terribly important but needs to be small, quick and out of the way when* needed.
Let’s say you’re updating a cart to a busy server, not an intensive process but can be slow. You still need to interact with the user and that all happens in the event loop.
* when the loop magic allows time for them
great!
Hi Koushik, can web workers communicate amongst themselves? webWorker1 and webWorker2 for example
Can you please tell us what software you are using to edit video.
Sir, have you created multithreading and concurrency tutorial? Please create tutorial in this. These concepts are hard to understand
why do we not just move the lessImportantFunction after the moreImportantFunction? Feels like that would be more of an intuitive way that doing the setTimeout(fn,0)?
Use case one. just reorder function call .no need for settineout
Hello Sir, Please make one series on Nashorn JavaScript. The amount of contents on internet are very very less. Please address this. Thank You..!!
I always used setTimeout with 0ms as the time, but only now do I properly understand what it's actually doing
Can anybody tell me pls what is the bug in the 2nd method?
So at the end is Nodejs a similar Java runtime ? since web workers were lunched ? at the end the difference between Java ecosystem and Javascript is only the fact that JS is a loosly typed, flexible language ?! It seems like there is a mimication or recreation or lets say highjacking of the Java ecosystem and a community revolution against Oracle passed supremacy, a community revolution supported by Google through v8 engin... ? is it right ?
Is event loop concept also in javascript?
9:26 when you explain strategy 2
function processArray(bigArray, start)
I think it will only execute once, because right after the forloop, start get increased by BATCH_SIZE while BATCH_SIZE remain the same the whole time
He told that there is a bug in the code, the condition should have been "i < start + BATCH_SIZE" instead of "i < BATCH_SIZE"
How it will be start + batch size? Batch size is the size of the array and loop can't exceed batch size.