How to delete a property from a JavaScript object based on the type of the property?

I want to write a utility file which will be passed a js object with “n” properties. This utility file should delete all the properties from the object whose value is either an array or a nested object and then return it.

Ideally, it can also create a new object and include all properties from the passed object other than array values and nested objects.

I tried using destructing but didn’t find any way to delete properties based on type.

How can this be achieved ?