# Iterating object properties

**URL:** <https://community.appfarm.io/t/iterating-object-properties/1577>\
**Category:** Ask the community\
**Created:** [January 7, 2025, 10:31am UTC](https://community.appfarm.io/t/iterating-object-properties/1577 "2025-01-07T10:31:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/ryan/32/1279_2.png) [@Ryan](https://community.appfarm.io/u/Ryan)\
**Post date:** [January 7, 2025, 10:31am UTC](https://community.appfarm.io/t/iterating-object-properties/1577/1 "2025-01-07T10:31:29Z")

</div>

Hi!

I would like to ask about whether it is possible to iterate object properties. This is especially useful when an object has many properties. It would be both faster and less prone to mistakes.

I have a specific use case where I want to update all properties of object A with object B (of the same type), provided that object B has a non-null value for the corresponding property. This is the code I have written:

function updatePropertiesIfNotNull(target, updates) {  
if (updates.length !== 1) {  
throw new Error(“The updates list must have exactly one object.”);  
}

const updateObject = updates[0]; // Extract the single object

for (const key in updateObject) {  
if (updateObject[key] !== null && updateObject[key] !== undefined) {  
target[key] = updateObject[key];  
}  
}  
}

The problem here is that I cannot directly update a function parameter. Please advise, thanks!

---

<div class="post-metadata">

**Author:** ![Shahitha](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/shahitha/32/66_2.png) [@Shahitha](https://community.appfarm.io/u/Shahitha)\
**Post date:** [January 9, 2025, 9:04am UTC](https://community.appfarm.io/t/iterating-object-properties/1577/2 "2025-01-09T09:04:56Z")

</div>

Hi!

You could try using the Update Object action node instead.

If I understand your use case it would be possible to solve this by using an Update object that has a filter (=object A). In the function editor you can add the object class as a function parameter and filter that on object B and return the properties.

Let us know if this helps.

---

<div class="post-metadata">

**Author:** ![Ryan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/ryan/32/1279_2.png) [@Ryan](https://community.appfarm.io/u/Ryan)\
**Post date:** [January 9, 2025, 9:58am UTC](https://community.appfarm.io/t/iterating-object-properties/1577/3 "2025-01-09T09:58:54Z")

</div>

Hi Shahitha,

If you were to use Update Object, I would have to bind every property individually which is too time-consuming when there are many properties. Or is there another way I am not seeing?

---

<div class="post-metadata">

**Author:** ![Shahitha](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/shahitha/32/66_2.png) [@Shahitha](https://community.appfarm.io/u/Shahitha)\
**Post date:** [January 9, 2025, 10:47am UTC](https://community.appfarm.io/t/iterating-object-properties/1577/4 "2025-01-09T10:47:13Z")

</div>

That is the only way to properly update the objects. Hopefully just a one-time thing!
