4 ms·
Not hard: msg can be derived from the parameter name of the send() function and status is a fixed attribute of the result.
by bassdigit 3y ago
Not hard: msg can be derived from the parameter name of the send() function and status is a fixed attribute of the result.
- jameshart 3y agoEven 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.