I'm building a simple clone function:
function clone (value) {
return JSON.parse(JSON.stringify(value))
}
The problem is that I need to do this also:
JSON.parse(JSON.stringify({}, object))
and:
JSON.parse(JSON.stringify({}, value, object))
How to modify my clone fuction to accept those additional params without breaking it?
object
? and wouldn't JSON.parse(JSON.stringify({})) result in an empty object regardless ofvalue
orobject
?