This makes the js fags seether

this makes the js fags seether

Attached: Screenshot_2022-07-23_17-40-38.png (390x124, 5.57K)

Other urls found in this thread:

developer.mozilla.org/en-US/docs/Web/API/Element/animationend_event
twitter.com/NSFWRedditVideo

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

How disgusting

Attached: IMG_20190815_130524_372.jpg (960x540, 55.99K)

>75 vs 8 characters
also, great std you got there senpai

Function doesn't actually sleep, you now have to await/async everything forever, or .then() chain forever.

>does not understand js
bruh, getting filtered by js is like being even lower than pajeet
actually, no it does not. In js there is *never ever* any need for anything to sleep.

>.then() chain forever
reminds me of that indian kid
sleep.then.do.new.style.then.element.then.in.await.set.sleep.then.do.new.style.then.element.then.in.await.set.new.style.then.element

kek

SetTimeout() something sonething

Is there a reason you can't have your script entry point be:
window.addEventListener("load", async () => {
// code ...
});

Then you can use async/await in every function you need to.

how about waiting for a css animation to finish?

Or if you don't want to use event listeners, use an async self calling function.
(async () => {
// code ...
})();

developer.mozilla.org/en-US/docs/Web/API/Element/animationend_event

Define sleep function in 8 characters in any language of your choice.

>actually, no it does not. In js there is *never ever* any need for anything to sleep.
exactly this

sleep is pajeet cope for when you don't understand how to do async

what makes me seethe is that there are people who want to use sleep for anything

even worse: sleep in any language is most likely a sign of rotten code

The only thing sleep() is useful for is if you want to artificially limit the execution speed for some reason, maybe you want a scraper to make new connections slower for example.

Sleep is useful when dealing with scrappers or gamedev. It is always used in async context too.
However is more than enough for all these cases.

>NOOOOOOO YOU CAN'T JUST BLOCK THE MAIN THREAD BECAUSE... BECAUSE YOU JUST CAN'T, OK?

In those cases a timeout is completely fine. Sleep is historically defined as something different and considering all the shit that we get from js: having no sleep, is a good thing.

>In those cases a timeout is completely fine
Timeout results in callback hell and borked error handling. Also you can't really put them inside loops. await sleep(time); is most reasonable way to do it.

that's based af
> want to make GET request
> too based to worry about fag shit like async/await or promises
> arbitrarily estimate how long the request should take, like 3 seconds
> make the request and immediately after it run "sleep(3)"
> rename main to master
> commit to master
> refuse to "fix" it
> revert back the "fixes" trannies made to it

That's the function definition you stupid fuck. Get the fuck off of Any Forums.

you're disgusting

top level await is a thing now, you don't need this

Promise
this is the gayest language

well, that sells it

Please don't bully us jscels. Nobody likes js, but we all have to know it because everything touches js at some point.

Go ahead soijack. Block the main thread in any GUI application, I dare you.

>Nobody likes js
bullshit, JS is better than most.

Wrong. There are many times when sleep is useful. For example let's say i am interfacing with a device and I notice it takes a while to start up. Should I create some convoluted system to detect when the chip starts up with an interrupt or just put a sleep and wait a couple 100us? Any other way is retarded that. sleep(200) jobs done I fixed the issue. The linux kernel is filled with sleeps you can grep it yourself because its usually the best way to wait.

>itt: blocking chuds who can't wrap their head around asynchronous programing
ok, boomer. go back to your cobol or whatever.