Compacting this repetitive JavaScript bit which trims values in an object shippingAddress.first_name = shippingAddress.first_name.trim()
    shippingAddress.last_name = shippingAddress.last_name.trim()
    shippingAddress.address1 = shippingAddress.address1.trim()
    shippingAddress.address2 = shippingAddress.address2.trim()
    shippingAddress.phone = shippingAddress.phone.trim()
    shippingAddress.city = shippingAddress.city.trim()
    shippingAddress.province = shippingAddress.province.trim()
    shippingAddress.country = shippingAddress.country.trim()
    shippingAddress.zip = shippingAddress.zip.trim()


What is a more elegant way to write this? I am thinking I can map it somehow or use something similar to Ruby's inject but I'm not sure.
With single traversal on keys list and trimming all fields of type string:

Object.keys(shippingAddress).forEach((k) =&gt; {
    if (typeof shippingAddress[k] == 'string') {
        shippingAddress[k] = shippingAddress[k].trim();
    }
})