I would recommend taking a look at lodash's source to get an idea of how an efficient algorithm might look. On quick glance, defining the clone function inside deepClone is inefficient. The clone function also does not account for functions, which also are passed by reference.
1 comment
[ 3.0 ms ] story [ 14.8 ms ] thread