2 ms·
Even worse - you’re polluting your local namespace with names decided on by other code. I’m obviously not being serious about naming being hard in this example
by jameshart 3y ago
Even worse - you’re polluting your local namespace with names decided on by other code.
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.
- bassdigit 3y agoStill not hard: In that case, instead of msg use sendMsg AND/OR in the second statement use { status, msg: resultMsg }, or just result and later result.msg.