Objects, state and inputs to functions

i am a bit unsure on how to pass objects into functions that may update attributes of those objects in some useful way and then pass back the object with changes reflected.

I do need to use this function somewhat globally so the person object it manipulates must also be as global.

I’ve tried destructuring to the properties involved in the change, I’ve also tried arguments operator… so far nothing works consistently and globally in a way that is generic.

I am thinking maybe that the person needs to have state properties in order for the person to be manipulated this way from any or all modules.

Can any of you weigh in? Mosh… help a brotha out.

Biz

I don’t understand. Can’t a function update any object passed into it? Why does the object need to be global?

The objects need to be global enough that any modules I write can address them, filter through them, add data to their attributes, edit data in their attributes, remove data from their attributes, or things like that.

I get errors if i pass a person object into a function and within the function i refer to the object passed in. I’ve learned about value vs reference and tried stuff like putting {person} or $({person}) but none of this works… and trying to do person.attribute doesn’t work and even person.method(); doesn’t work either… so not sure what I’m missing… tried destructuring too, no luck yet.

I’m sure its something i’m missing.

Biz

Do you have a code example showing how you are passing the person object into a function and how that function is using that person object?

Thanks, I solved it my system was expecting a tuple but i was mistakenly sending in two inputs so thank you for helping me realize that an object should be able to be passed in by reference and their attributes should be accessible. It’s working now… but I also think I need to muse about state modeling. System needs to be able to recognize contexts in which people find themselves. Have a good week.

Biz