clone-array.js 241 B

123456789101112
  1. function cloneArray(array) {
  2. var cloned = array.slice(0);
  3. for (var i = 0, l = cloned.length; i < l; i++) {
  4. if (Array.isArray(cloned[i]))
  5. cloned[i] = cloneArray(cloned[i]);
  6. }
  7. return cloned;
  8. }
  9. module.exports = cloneArray;