const msg = capitalize(greeting) + “!”;
const { status } = await send(msg);
console.log(status);
Now it’s perfectly readable, no weird shenanigans required. const msg = capitalize(greeting) + “!”;
const { status } = await send(msg);
console.log(status);
Now it’s perfectly readable, no weird shenanigans required.You don't have to write something like "this is the message", you can see it.
I’m obviously not being serious about naming being hard in this example.
But there are cases where the pattern of using return object property names as variables comes back to bite uou.
Even in this case, what if the response object from ‘send()’ also has a ‘msg’ property?
Changing const { status } into const { status, msg } is an error.
We should be cautious about syntaxes that force us to allocate names. Sometimes.
But still I’ve done what people advised, for many years. And know what? It never paid back. I’m sort of tired to keep that secret and nod to this obvious overgeneralization and a blanket idea. Pretty sure I’m not alone.
[1] https://github.com/lua/lua/blob/6baee9ef9d5657ab582c8a4b9f88...