@rtemBondarenko const copyArray = array => {
const isArray = v => v instanceof Array
const isObject = v => !!(
v &&
v.constructor &&
v.constructor === Object
)
const copy = v => {
if ( v[0] ) {
if ( isArray( v ) ) { return iterateArray(v) }
if ( isObject( v ) ) { return iterateObject(v) }
else { return v }
}
else { return v }
}
const iterateObject = o => {
return Object.entries( o ).map( ([k,v]) => {
return copy( v )
})
}
const iterateArray = a =>
a.map( v => {
return copy( v )
})
return copy( array )
}