nstatistics
Version:
Solve equations using numerical methods, linear álgebra and solver of linear equation system
14 lines • 449 B
JavaScript
// recursive function to clone an object. If a non object parameter
// is passed in, that parameter is returned and no recursion occurs.
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;
}
module.exports = cloneObject