r/javascript • • Feb 07 '20

How I improve my Javascript Coding Skill every day

https://medium.com/javascript-in-plain-english/how-i-improve-my-javascript-coding-skill-every-day-37ccf2feacf4
2 Upvotes

20 comments sorted by

26

u/[deleted] Feb 07 '20

One simple trick! Stop reading Medium!

5

u/mainstreetmark Feb 07 '20

One irritating thing about that site is the top banner shoots back down if you scroll up just a tiny bit. This, naturally, requires you to scroll up even more.

Therefore, dread washes over me whenever i realize i'm on a Medium article.

7

u/R3gouify Feb 07 '20

" The nature of await is that it will wait until the Promise returns the value, so sometimes use await too much will make our app slow." - I'm pretty sure this is not true. The function is async so it will not slow down the app. When some function is async, await calls will wait for it to finish but it will not block the thread; instead the browser will handle other stuff while it is waiting for that promise to reject or resolve.

7

u/kondv Feb 07 '20

I think he means that the async function will block until the await resolves so multiple awaits that depend on one another could be slower.

6

u/[deleted] Feb 07 '20

Which is where Promise.all() really shines.

1

u/ulisesgomez120 Feb 07 '20

It's explained pretty well in this video when await can make your code slower. Around 7:50 mark if you wanted to just skip to it.

https://youtu.be/vn3tm0quoqE

2

u/Arthelon_ Feb 07 '20

Medium paywall is giving me an excuse not to improve my JavaScript skills every day /s

2

u/geekdenz Feb 08 '20

If you want to watch videos I recommend the funfunfunction channel on YouTube. However, you can basically get infinite practice on sites like HackerRank, LeetCode and CodeChef. I highly recommend learning algorithms that way. If you start with easy and do all of those questions first it should keep you busy for a long time and your coding skills will improve all the time.

1

u/p_whimsy Feb 07 '20

async function test () {

try {

const users = await axios.get('/users')

const addresses = await axios.get('/addresses')

} catch (error) {

console.log(error)

}

}

test()

I realize there's a chance I'm being a moron asking this, but in this case isn't it... a bit pointless to set the users and addresses to constants within the try block which is within the test function? Unless there's something about async/await that I'm missing, it appears that those variables constants are set and the data isn't even console logged or anything. You essentially have two useless variables constants

... right?

1

u/LollipopPredator Feb 07 '20

well yea, but if you wanted to do anything with users and addresses...

1

u/CodyCigar96o Feb 07 '20

I personally believe you should always strive to not need to write comments at all. They’re a code smell in themselves in a sense.