@[email protected] to [email protected]English • 6 hours agoProgramming in simple 4 stepsprogramming.devimagemessage-square29fedilinkarrow-up1437arrow-down112
arrow-up1425arrow-down1imageProgramming in simple 4 stepsprogramming.dev@[email protected] to [email protected]English • 6 hours agomessage-square29fedilink
minus-square@BrianTheeBiscuiteerlink1•edit-22 hours agoWhat’s the purpose of foo? Why an ambiguous single character variable? What if the property was there but the value was null? Why not use (assuming JS) optional chaining? I’d approach it more like this: function getWhatevrProp(userData) ( const default = { whatevr: "n/a" }; return { ...default, ...userData }.whatevr; } Sorry, read too fast the first time. It’s more likely Python. I also don’t know Python well enough to give recommendations on that.
What’s the purpose of foo? Why an ambiguous single character variable? What if the property was there but the value was null? Why not use (assuming JS) optional chaining?
I’d approach it more like this:
function getWhatevrProp(userData) ( const default = { whatevr: "n/a" }; return { ...default, ...userData }.whatevr; }
Sorry, read too fast the first time. It’s more likely Python. I also don’t know Python well enough to give recommendations on that.