vuejs / docs

šŸ“„ Documentation for Vue 3
https://vuejs.org
Other
2.81k stars 4.1k forks source link

docs (#2528): add references to help people new to getter functions iā€¦ #2817

Closed bencodezen closed 2 weeks ago

bencodezen commented 3 weeks ago

Description of Problem

Getter functions are referenced a lot in docs, but if you're new to JS, it is unclear whether this is a Vue thing or a JS thing.

Proposed Solution

Similar to how acronyms are defined at the beginning of each article before being used throughout the rest, adding a link referencing to what getters / setters are can help provide clarity to people newer to JavaScript and haven't encountered these concepts yet.

Additional Information

Related issue #2528

netlify[bot] commented 3 weeks ago

Deploy Preview for vuejs ready!

Name Link
Latest commit 2aaff24b6c4dd29d0373275617abf6e3fdb6a793
Latest deploy log https://app.netlify.com/sites/vuejs/deploys/66293f4a0a1ad2000875b892
Deploy Preview https://deploy-preview-2817--vuejs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

brc-dd commented 3 weeks ago

I don't think getter function in Vue's context is same as get syntax. It's more like any function that returns something.

That MDN link just shows things like const foo = { get bar() { return 1 } }. If one is reading that link and will try to apply that to, say, computed it won't work.

AloisSeckar commented 3 weeks ago

I don't think getter function in Vue's context is same as get syntax.

Then perhaps a better approach would be to include it into Glossary under its own label? šŸ¤”

nielsbom commented 3 weeks ago

Any idea why the term "getter function" is used so consistently?

Maybe use "value-returning-function" or "function that returns a value" instead to make it more clear that it's not a special concept?

bencodezen commented 3 weeks ago

I don't think getter function in Vue's context is same as get syntax. It's more like any function that returns something.

That MDN link just shows things like const foo = { get bar() { return 1 } }. If one is reading that link and will try to apply that to, say, computed it won't work.

Further down in the description, there's the following snippet:

The getter syntax allows you to specify the getter function in an object initializer.

I believe this is the concept that we are referring to, though maybe I'm wrong.

nielsbom commented 2 weeks ago

W00t!