Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function arguments (2 or fewer ideally) - Talks about destructing but I don't see destructing used #45

Closed
bluEEil opened this issue Apr 14, 2021 · 1 comment
Labels
question Further information is requested

Comments

@bluEEil
Copy link

bluEEil commented Apr 14, 2021

In the example of "Function arguments (2 or fewer ideally)"
There is a talk about destrcuting, which to what I know is:

const object = {a: 1, b: 2};
const {a, b} = object; // This is destrcuting

Now what the code there does is

function createMenu(options: { title: string, body: string, buttonText: string, cancellable: boolean }) {
  // ...
}

createMenu({
  title: 'Foo',
  body: 'Bar',
  buttonText: 'Baz',
  cancellable: true
});

I can't find the destructing here (I don't think declaring option type should be considered as destructing.
In the "Set default objects with Object.assign or destructuring" the last example actually does use destructing unlike in this example.
Maybe the paragraph of "Function arguments" should be changed? Or am I missing something here?

@dimadeveatii
Copy link
Member

@bluEEil take a look at this example in README:

function createMenu({ title = 'Foo', body = 'Bar', buttonText = 'Baz', cancellable = true }: MenuConfig) {
  // ...
}

The function argument is destructured to access fields and give them default values.

@dimadeveatii dimadeveatii added the question Further information is requested label Apr 26, 2022
@dimadeveatii dimadeveatii closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants