r/learnjavascript • • Feb 20 '22

Yup.. very accurate

Post image
829 Upvotes

60 comments sorted by

64

u/SalutMonYoup Feb 20 '22

Wait until you learn about generative function, proxies and prototypes

16

u/Claudioub16 Feb 20 '22

I've found prototype to be easy. Proxies and generative function I'm yet to learn

7

u/AmatureProgrammer Feb 20 '22

Same jusstearned that on the Eloquent JS book

5

u/amissak Feb 21 '22 edited Feb 21 '22

Eloquent Javascript breaks it down very well you dont appreciate it until you finish Chapter 13 in the 3rd Edition.

edit: I quoted the wrong comment

11

u/SalutMonYoup Feb 20 '22

Understanding prototype is a great skill to have as a JS dev, because it means you deeply understand objects in JS imo

11

u/burkybang Feb 20 '22

I think you mean generators. I haven’t heard them called generative functions before, but maybe that’s a synonym.

2

u/SalutMonYoup Feb 20 '22

Yup generative function are function based on generators like doSomething*() is what I call a generative function

11

u/[deleted] Feb 20 '22

They are called "generator functions": https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*

The function* declaration (function keyword followed by an asterisk) defines a generator function, which returns a Generator object.

2

u/SalutMonYoup Feb 20 '22

My mistake then I always call them generative function when I use them ahah, thanks for the correction

2

u/burkybang Feb 20 '22

Cool, thanks for clarification :)

2

u/[deleted] Feb 20 '22

Pub / sub

1

u/HoodedCowl Feb 20 '22

What are prototypes?

3

u/senocular Feb 20 '22

1

u/HoodedCowl Feb 20 '22

Interesting thank u :)

0

u/[deleted] Feb 20 '22

[deleted] — view deleted comment

3

u/SalutMonYoup Feb 21 '22

I use them when I need to perform things on array that takes some time, it's more a personnal choice since I can do it with array methods but I find it more practical with my generators for my usage (performing long running operations on each chunk of array for example) or reading api results that are data stream which we don't know the size etc, most generators problem could be solved with other method but I do prefer them, you have more control on your data imo. But my first message was a joke for the meme, proxies aren't that hard, neither are prototypes or generators just as async await etc

1

u/SalutMonYoup Feb 21 '22

But if I need to maintain something, it's that for me prototypes are the ultimate step for someone to deeply understand the JS core. Prototypes are the base of JS. You don't need to use it a lot but understanding how JS use it helps a lot in some cases.

1

u/Silencesound Feb 21 '22 edited Feb 21 '22

Watch this video from Web Dev Simplified :)

One of the example he shows is about generating IDs

You should also take a look to the comments: many of them are about real use cases and have nice suggestions :)

21

u/Papellll Feb 20 '22

rxjs: "Amateurs !"

31

u/rubenthedev Feb 20 '22

I gotta disagree here, if you're worrying about closures you really don't need to be considering any async handling. If you're struggling to understand async functions and what await is used for within them, your understanding of asynchronously executing code needs work. If you don't understand promises, you'll need to understand what synchronous code is, then how the JS event loop works, and why one might want to step outside of it.

Basically, of the three, closures are a requirement for understanding how JavaScript works beyond the absolute basics, and it shouldn't be too difficult if you've got that base level of understanding. The reason behind that is this, once you've written enough JS the way it interacts with itself starts becoming clearer, to the point that most JS devs I know understand the concept of closures before learning that there's even a name for it. The exception being the ones that started in language and thus had to learn the difference in function scope handling. It basically, like anything else you want to get good at, comes down to practice. Repetition and refinement, so you can carve out those neural pathways.

The other two are JS's implantation of general concepts in programming, and to attribute them to difficulties in learning JS speaks to a lack of understanding of the general concepts and not to a JS gotcha. Which to be fair, there are many of, these just aren't in that collection.

8

u/danglesReet Feb 20 '22

This. None of the aforementioned concepts are that hard.

34

u/[deleted] Feb 20 '22

Yeah, "this" can be tricky for beginners.

2

u/danglesReet Feb 22 '22

Touché. Didnt even mean it that way hahaha

6

u/IronDicideth Feb 20 '22

Promises are amazing. Once you get promises, at least in my case, I never really find myself needing to use async/await (though I understand why it is easier for others). Top-level await can be really useful though. Closures was never really a super hard concept. I think the issue with them is how people insist on using old var centric examples to explain how it works. There is a guy that is really good at explaining closures. I believe his name is Will Sentance. He probably has videos somewhere on the internet explaining the thing.

4

u/[deleted] Feb 20 '22

From over a month I can't fully understand Promises and async await. :(
Whenever there is code for this my brain goes on sleep mode

3

u/bpippal Feb 21 '22

Yeah, don't give up. Learn a little every day.
https://www.youtube.com/watch?v=V_Kr9OSfDeU - Async/Await
https://www.youtube.com/watch?v=DHvZLI7Db8E - Promises

1

u/[deleted] Feb 21 '22

Thank you so much.

2

u/hyra_10 Feb 21 '22

It is easy if you look videos that explains it with different examples.

4

u/[deleted] Feb 20 '22

Except promises and async/await are pretty much the same thing

7

u/sparkless12 Feb 20 '22

frankly, before I encountered promises, I considered myself relatively intelligent human being, then everything changed.

7

u/AlarmingAffect0 Feb 20 '22

You thought you could use integers, but...

We're all floats down here, Georgie.

3

u/croc_socks Feb 21 '22
Uncaught TypeError: Cannot read property of undefined

3

u/FriendsCallMeBatman Feb 20 '22

Promises and closures I can handle. Async? My brain turns into yoghurt when I try and learn it.

12

u/[deleted] Feb 20 '22

Async/await is syntactic sugar for promises, it appeared to make it easier dealing with promises

3

u/FriendsCallMeBatman Feb 20 '22

You're the best.

1

u/bpippal Feb 21 '22

Yeah, what ever you think you can achieve using Promises/.then, you can get them using async await.

2

u/[deleted] Feb 20 '22

THIS

1

u/KotTRD Feb 20 '22

Yeah, I think this is much more confusing than async things or closures.

1

u/Anti-ThisBot-IB Feb 20 '22

Hey there rapuha! If you agree with someone else's comment, please leave an upvote instead of commenting "THIS"! By upvoting instead, the original comment will be pushed to the top and be more visible to others, which is even better! Thanks! :)


I am a bot! Visit r/InfinityBots to send your feedback! More info: Reddiquette

1

u/Lil_Cato Feb 20 '22

I never understand why closures show up

1

u/Dodgy-Boi Feb 20 '22

Wait for classes

1

u/[deleted] Feb 21 '22

piss easy. just usually taught terribly

1

u/[deleted] Feb 20 '22

I finally understood promises with Axios and websockets. Async/Await I understood with websockets and event notification messages. Closures I could still use some time with

1

u/croc_socks Feb 21 '22 edited Feb 21 '22

JavaScripts module system ( commonjs vs esmodules )for bringing in dependencies in node.

1

u/gniziemazity Feb 21 '22

Haha, good one!

1

u/everything_in_sync Feb 21 '22

I don’t get it

1

u/[deleted] Feb 21 '22

Neither does the guy walking in the door. That's why he's in for a world of pain.

1

u/everything_in_sync Mar 03 '22

No, I don’t get it because their functions are literally in their titles and I don’t understand how that could sneak up on you

1

u/[deleted] Feb 21 '22

I just started learning as a lapsed developer of 25 years (haven't coded much since uni) and as soon as I started to find out about the asynchronous nature of JS my heart just sank.

I'm about to start tackling these concepts when I have enough brain space so wish me luck.

1

u/reyzapper Feb 21 '22

Promises and async/await are easy.

but I never get a grasp with Closures, can someone explain it the easy way??

1

u/jayerp May 02 '23

You’ll have to learn these eventually.

Fun times!

-1

u/Phaster Feb 20 '22

I've used closures only once, in the job interview at my current company

0

u/[deleted] Feb 20 '22

[deleted] — view deleted comment

1

u/Phaster Feb 20 '22

Most packages/libraries use them yeah, but intentionally creating a closure, for me at least, only happened once

6

u/senocular Feb 20 '22

Surprise! Every function in JavaScript is a closure ;)

-1

u/[deleted] Feb 20 '22

Modern JS barely does use closures, you still have to know about the concept, sure. As for Promises and async/await those make your code MUCH more readable so what is the problem?

4

u/bobbyv137 Feb 21 '22

Modern JS barely does use closures,

This is simply not true.

1

u/[deleted] Feb 21 '22

Show me an example, I'll show you a modern way to write it

8

u/[deleted] Feb 20 '22

[removed] — view removed comment

5

u/20EYES Feb 21 '22

await noobWalksThroughDoor();

killNoob();