code: function clone(obj) {
    if (typeof obj == 'function') {
      return obj;
    }
    var result = Array.isArray(obj) ? [] : {};
    for (var key in obj) {
      // include prototype properties
      var value = obj[key];
      var type = {}.toString.call(value).slice(8, -1);
      if (type == 'Array' || type == 'Object') {
        result[key] = clone(value);
      } else if (type == 'Date') {
        result[key] = new Date(value.getTime());
      } else if (type == 'RegExp') {
        result[key] = RegExp(value.source, getRegExpFlags(value));
      } else {
        result[key] = value;
      }
    }
    return result;
  }
docs: /*
  Deep clones all properties except functions
  
  var arr = [1, 2, 3];
  var subObj = {aa: 1};
  var obj = {a: 3, b: 5, c: arr, d: subObj};
  var objClone = clone(obj);
  arr.push(4);
  subObj.bb = 2;
  obj; // {a: 3, b: 5, c: [1, 2, 3, 4], d: {aa: 1}}
  objClone; // {a: 3, b: 5, c: [1, 2, 3], d: {aa: 1, bb: 2}}