lib/abaaso.js
function ( obj, shallow ) {
		var clone;

		if ( shallow === true ) {
			return json.decode( json.encode( obj ) );
		}
		else if ( !obj || regex.primitive.test( typeof obj ) || ( obj instanceof RegExp ) ) {
			return obj;
		}
		else if ( obj instanceof Array ) {
			return obj.slice();
		}
		else if ( !server && !client.ie && obj instanceof Document ) {
			return xml.decode( xml.encode( obj ) );
		}
		else if ( typeof obj.__proto__ !== "undefined" ) {
			return utility.extend( obj.__proto__, obj );
		}
		else if ( obj instanceof Object ) {
			// If JSON encoding fails due to recursion, the original Object is returned because it's assumed this is for decoration
			clone = json.encode( obj, true );

			if ( clone !== undefined ) {
				clone = json.decode( clone );

				// Decorating Functions that would be lost with JSON encoding/decoding
				utility.iterate( obj, function ( v, k ) {
					if ( typeof v === "function" ) {
						clone[k] = v;
					}
				});
			}
			else {
				clone = obj;
			}

			return clone;
		}
		else {
			return obj;
		}
	}
function ( obj, shallow ) {
		var clone;

		if ( shallow === true ) {
			return json.decode( json.encode( obj ) );
		}
		else if ( !obj || regex.primitive.test( typeof obj ) || ( obj instanceof RegExp ) ) {
			return obj;
		}
		else if ( obj instanceof Array ) {
			return obj.slice();
		}
		else if ( !server && !client.ie && obj instanceof Document ) {
			return xml.decode( xml.encode( obj ) );
		}
		else if ( typeof obj.__proto__ !== "undefined" ) {
			return utility.extend( obj.__proto__, obj );
		}
		else if ( obj instanceof Object ) {
			// If JSON encoding fails due to recursion, the original Object is returned because it's assumed this is for decoration
			clone = json.encode( obj, true );

			if ( clone !== undefined ) {
				clone = json.decode( clone );

				// Decorating Functions that would be lost with JSON encoding/decoding
				utility.iterate( obj, function ( v, k ) {
					if ( typeof v === "function" ) {
						clone[k] = v;
					}
				});
			}
			else {
				clone = obj;
			}

			return clone;
		}
		else {
			return obj;
		}
	}
function ( obj , shallow ) { var clone ; if ( shallow === true ) { return json . decode ( json . encode ( obj ) ) ; } else if ( ! obj || regex . primitive . test ( typeof obj ) || ( obj instanceof RegExp ) ) { return obj ; } else if ( obj instanceof Array ) { return obj . slice ( ) ; } else if ( ! server && ! client . ie && obj instanceof Document ) { return xml . decode ( xml . encode ( obj ) ) ; } else if ( typeof obj . __proto__ !== "undefined" ) { return utility . extend ( obj . __proto__ , obj ) ; } else if ( obj instanceof Object ) { // If JSON encoding fails due to recursion, the original Object is returned because it's assumed this is for decoration clone = json . encode ( obj , true ) ; if ( clone !== undefined ) { clone = json . decode ( clone ) ; // Decorating Functions that would be lost with JSON encoding/decoding utility . iterate ( obj , function ( v , k ) { if ( typeof v === "function" ) { clone [ k ] = v ; } } ) ; } else { clone = obj ; } return clone ; } else { return obj ; } }
Clones an Object

@method clone
@param {Object}  obj     Object to clone
@param {Boolean} shallow [Optional] Create a shallow clone, which doesn't maintain prototypes, default is `false`
@return {Object}     Clone of obj
Clones an Object