Trim() every string in a JavaScript object?
I see a bug for a null property case as typeof null == "object". You should check if it's not null or an object :)

Another less important? bug is you can't use the key hasOwnProeprty on any of your objects. You can get around this by using Object.prototype.hasOwnProperty.call(obj, key)

Only obvious optimization I see is to move the hasOwnProperty check after the typeof check. hasOwnProperty is a relatively expensive function so you will probably see some gains off that. I expect this should be even faster than doing Object.keys which is known to be faster than your for in has loop...

I assume you're polyfilling trim for older browsers right?

function DeepTrim(obj) {
    for (var prop in obj) {
        var value = obj[prop], type = typeof value;
        if (value != null &amp;&amp; (type == "string" || type == "object") &amp;&amp; obj.hasOwnProperty(prop)) {
            if (type == "object") {
                DeepTrim(obj[prop]);
            } else {
                obj[prop] = obj[prop].trim();
            }
        }
    }
}