r/JavaScriptTips • • Mar 16 '23

Why theme doesn't have value ? When doing so ?

Post image
4 Upvotes

3 comments sorted by

1

u/Ironclad_57 Mar 16 '23

I’m pretty new in Js, but I believe

This would read as

theme: theme;

Similar to when you use like a factory function const make = (propVal) => { return { propVal; }; };

So let made = make(5); Would make an object like {propVal: 5}

1

u/Ironclad_57 Mar 16 '23

The the value of your theme property is the value of the theme variable

1

u/Ironclad_57 Mar 16 '23 edited Mar 16 '23

As for the rest operator, like I said I’m pretty new myself, but in my experience chatGPT likes to not assume that arguments will be entered as expected so probably just threw it in for safesies but I’m not positive

Unless it’s being used as a Spread operator on the Object? Any reason you would need to be iterating over the properties of Object?