function cloneObject( obj ) {
  if ( obj === null || typeof obj !== 'object' ) {
    return obj;
  }
  var temp = obj.constructor( ); // give temp the original obj's constructor
  for ( var key in obj ) {
    temp[ key ] = cloneObject( obj[ key ] );
  }
  return temp;
}
function cloneObject( obj ) {
  if ( obj === null || typeof obj !== 'object' ) {
    return obj;
  }
  var temp = obj.constructor( ); 
  for ( var key in obj ) {
    temp[ key ] = cloneObject( obj[ key ] );
  }
  return temp;
}
function cloneObject ( obj ) { if ( obj === null || typeof obj !== 'object' ) { return obj ; } var temp = obj . constructor ( ) ; // give temp the original obj's constructor for ( var key in obj ) { temp [ key ] = cloneObject ( obj [ key ] ) ; } return temp ; }
recursive function to clone an object. If a non object parameter is passed in, that parameter is returned and no recursion occurs.
recursive function to clone an object . If a non object parameter is passed in that parameter is returned and no recursion occurs .