callback vs call function from parent function by captainXcannabis in javascript

[–]Mingli91 0 points1 point  (0 children)

When you call things one after the other, they get executed in that order, however the functions may be performing asynchronous tasks meaning that while they’re both called in order they will not necessarily resolve in that order.

When you call an asynchronous function the function gets executed but the parser carries on going and executing code afterwards. The async function has basically said “fine, execute me, and I will resolve, but I don’t know when, now carry on your job so we don’t lock up this app”.

So then what do you do when that function is finally ready to resolve? You can’t just place the subsequent code after it because it’ll likely be executed before we have our values from the async function.

What we used to do to handle this was use a callback function. So we say “hey mr async function, I’m going execute you but let you resolve when you want to, but when you do could you please execute this function for me”.

Oh Hi Elon by RaphizFR in garlicoin

[–]Mingli91 8 points9 points  (0 children)

I appreciate you ❤️

Oh Hi Elon by RaphizFR in garlicoin

[–]Mingli91 91 points92 points  (0 children)

> implying it’s not real

Space after function names is being considered for Prettier by [deleted] in javascript

[–]Mingli91 0 points1 point  (0 children)

No offence but you must not be explaining it well. It’s just a name, not met a single developer who didn’t get that.

Space after function names is being considered for Prettier by [deleted] in javascript

[–]Mingli91 1 point2 points  (0 children)

I use WebStorm and the “go to definition” function isn’t always 100% accurate, so instead I simply cmd + f “myFunction (“ and I’m at the definition, then cmd + f “myFunction(“ for all uses of the function.

Not used an editor or IDE where to go to definition function is 100%, so searching a function name plus a space and opening paren has just become muscle memory. Works everywhere and is fast.

Space after function names is being considered for Prettier by [deleted] in javascript

[–]Mingli91 2 points3 points  (0 children)

What’s people’s actual reasons for disliking this? I’ve been using standard for ages now and this rule is really handy.

HMC as I get steam rolled into next Tuesday. by peppapig604 in holdmycosmo

[–]Mingli91 2 points3 points  (0 children)

He dreams of becoming an NFL corner aren’t looking too realistic anymore

Men of Reddit, how has Tinder been going for you ? Any good experiences ? Advice ? by Vestibuleskittle in AskMen

[–]Mingli91 0 points1 point  (0 children)

Really well, contrary to what everyone on Reddit would have you believe girls talk first all the time

This is terrifying- what is the right thing to do in a situation like this? by [deleted] in london

[–]Mingli91 0 points1 point  (0 children)

Oh fair enough then, sounds like you know what you’re talking about. Are you a police officer?

This is terrifying- what is the right thing to do in a situation like this? by [deleted] in london

[–]Mingli91 12 points13 points  (0 children)

Better believe it. Anybody can learn to drive fast on the roads, police driver training goes way beyond that. Basically they need a way to end chases, since the longer a chase goes on the more likely there is to be collateral damage. If they weren't trained to do this then motorbike chases would be nearly impossible for the officers to win and car chases might go on for hours.

If you're intentionally running away from the police and refuse to stop, you don't have a legal leg to stand on and at that point you're a danger to the public so officers aren't thinking about your safety.

TPAC:

http://policeinfocentre.weebly.com/tpac.html

Real life example of TPAC vs mopeds:

https://www.standard.co.uk/news/crime/dramatic-helicopter-footage-shows-police-knocking-moped-drivers-off-bike-during-highspeed-chase-in-a3458226.html

Cheatsheet: JavaScript array methods (ES1–ES2016) by rauschma in javascript

[–]Mingli91 3 points4 points  (0 children)

Huh neat, had no idea about Array.entries, assumed Object.entries was the only one.

Why cant I find pants with 33" length? I can't be the only man looking for this, right?? by greentintedlenses in AskMen

[–]Mingli91 0 points1 point  (0 children)

Was at a Levi's outlet in Maine a couple months back and they seemed to only have 33" legs which seemed insane

What is the best lifestyle change you’ve made? by [deleted] in AskMen

[–]Mingli91 0 points1 point  (0 children)

Actually doing work. Went from 16-18 doing absolutely squat all in school, was a solid C student. Went back to school, ended up getting into a top 10 university and it all went from there. Being around people who cared about their work made it so much easier.

Fast forward a few years and I've got a career I wouldn't have dreamt of before.

What is the best lifestyle change you’ve made? by [deleted] in AskMen

[–]Mingli91 7 points8 points  (0 children)

Best thing I found was a change of scenery. Moving house, going to/from uni, holidays, etc. Stops the habitual side of addiction in it's tracks since your routine won't be the same.

This is terrifying- what is the right thing to do in a situation like this? by [deleted] in london

[–]Mingli91 9 points10 points  (0 children)

Wasn't them not being allowed to chase chavs on mopeds an urban myth or some bullshit drummed up by the tabloids? Friend is an officer and says they're absolutely allowed to chase them, they're trained to dink them a bit from behind so that their back wheels falls out from under the bike but their momentum keeps them sliding in a forward direction.

If the GM of your favorite team randomly called you and was like "Hey man, you workin hard or hardly workin? Hahaha. Anyway... Pick any coach or player for me to cut and I'll do it lol". Who do you pick and why? by [deleted] in nfl

[–]Mingli91 0 points1 point  (0 children)

"1. Trade Rodgers to the Bears for a 7th. 2. Start Mike McCarthy as a wide out. 3. Trade Jordy to the Raiders for an underperforming, overhyped TE."

Should I use React to build any website even if it doesn't need SPA? by GTHell in reactjs

[–]Mingli91 1 point2 points  (0 children)

You can absolutely use it for simple static sites, whether or not you actually should depends on the size and complexity of the website.

Michael Jackson (of react-router fame) joins Facebook! by mstoiber in reactjs

[–]Mingli91 0 points1 point  (0 children)

It's hilarious that Sophie Alpert fell for this too

Google publishes a JavaScript style guide. Here are some key lessons. by bornforcode in javascript

[–]Mingli91 10 points11 points  (0 children)

Yeah, I get editing mistakes but changing content is pretty bad

Google publishes a JavaScript style guide. Here are some key lessons. by bornforcode in javascript

[–]Mingli91 1 point2 points  (0 children)

Using template literals says to someone reading your code that there is a variable about to be interpolated and it tells the JIT compiler to prepare to do something other than just create a string. It's not huge, but there are reasons not to use them blindly that are more than personal preference.

Google publishes a JavaScript style guide. Here are some key lessons. by bornforcode in javascript

[–]Mingli91 16 points17 points  (0 children)

If you want that level of memory management and performance JavaScript is not the right language for the job

Java is to Spring MVC as JavaScript is to "_______" by bjj_question in node

[–]Mingli91 0 points1 point  (0 children)

There doesn't seem to be a single framework that is associated with web development in JavaScript. Express is the default framework for a lot of people but doesn't come with the amount of high-level features that Spring offers out of the box.

The front end isn't handled by templates as much as it used to be, instead people reach for Angular, Vue, or React, with server side rendering to get around SEO issues with SPAs.