This is absolutely not helpful, when you are trying to find out what kind of keys do the config object accept.
function createMenu(config) {
// ...
}
createMenu({
title: 'Foo',
body: 'Bar',
buttonText: 'Baz',
cancellable: true
});
This however makes it perfectly clean exactly which keys are used:
function createMenu({ title, body, buttonText, cancellable }) {
// ...
}
There are no sneaky magic properties accessed in the call chain later, since you don't have the reference to the original config object. I would highly recommend suggesting this version. Also while coding, if you have a linter, it will tell you if you have an unused prop in the destrucutured object while it will have no chance of warning you if you just take it as a regular argument.
This is absolutely not helpful, when you are trying to find out what kind of keys do the
configobject accept.This however makes it perfectly clean exactly which keys are used:
There are no sneaky magic properties accessed in the call chain later, since you don't have the reference to the original
configobject. I would highly recommend suggesting this version. Also while coding, if you have a linter, it will tell you if you have an unused prop in the destrucutured object while it will have no chance of warning you if you just take it as a regular argument.