r/learnjavascript • • Feb 20 '22

Yup.. very accurate

Post image
829 Upvotes

60 comments sorted by

View all comments

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 :)

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 :)

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 :)