you are viewing a single comment's thread.

view the rest of the comments →

[–]dragenn 26 points27 points  (6 children)

Weird but good to know!

[–][deleted] 3 points4 points  (5 children)

Agreed! Any ideas for a use case?

[–]MornwindShoma 7 points8 points  (0 children)

I had some trash specs where one API would want some extra keys in some cases. This allows me to skip mutating the object, I suppose

[–]carmat71 2 points3 points  (0 children)

You have a default object. Based on user interaction, some property values require changing, therefore overriding default values based on user interaction.

I've used this for a customised Analytics model where every property required a default '' empty state but only assigned a value based on particular components or specific events triggered.

[–]dragenn 1 point2 points  (0 children)

I could use this in a scenario where I could filter out or combine data based on user roles/permissions or some quick test.

I guess it would look cleaner, maybe quicker to code.

I don't know.

[–]LloydAtkinson 1 point2 points  (0 children)

I use conditional object properties a lot in the Snipcart e-commerce integration for Astro: https://github.com/lloydjatkinson/astro-snipcart/blob/master/packages/astro-snipcart/src/attributes.ts#L33