libs/lodash.js
function baseClone(value, isDeep, callback, stackA, stackB) {
      if (callback) {
        var result = callback(value);
        if (typeof result != 'undefined') {
          return result;
        }
      }
      var isObj = isObject(value);
      if (isObj) {
        var className = toString.call(value);
        if (!cloneableClasses[className]) {
          return value;
        }
        var ctor = ctorByClass[className];
        switch (className) {
          case boolClass:
          case dateClass:
            return new ctor(+value);

          case numberClass:
          case stringClass:
            return new ctor(value);

          case regexpClass:
            result = ctor(value.source, reFlags.exec(value));
            result.lastIndex = value.lastIndex;
            return result;
        }
      } else {
        return value;
      }
      var isArr = isArray(value);
      if (isDeep) {
        // check for circular references and return corresponding clone
        stackA || (stackA = []);
        stackB || (stackB = []);

        var length = stackA.length;
        while (length--) {
          if (stackA[length] == value) {
            return stackB[length];
          }
        }
        result = isArr ? ctor(value.length) : {};
      }
      else {
        result = isArr ? slice(value) : assign({}, value);
      }
      // add array properties assigned by `RegExp#exec`
      if (isArr) {
        if (hasOwnProperty.call(value, 'index')) {
          result.index = value.index;
        }
        if (hasOwnProperty.call(value, 'input')) {
          result.input = value.input;
        }
      }
      // exit for shallow clone
      if (!isDeep) {
        return result;
      }
      // add the source value to the stack of traversed objects
      // and associate it with its clone
      stackA.push(value);
      stackB.push(result);

      // recursively populate clone (susceptible to call stack limits)
      (isArr ? arrayEach : baseForOwn)(value, function(valValue, key) {
        result[key] = baseClone(valValue, isDeep, callback, stackA, stackB);
      });

      return result;
    }
function baseClone(value, isDeep, callback, stackA, stackB) {
      if (callback) {
        var result = callback(value);
        if (typeof result != 'undefined') {
          return result;
        }
      }
      var isObj = isObject(value);
      if (isObj) {
        var className = toString.call(value);
        if (!cloneableClasses[className]) {
          return value;
        }
        var ctor = ctorByClass[className];
        switch (className) {
          case boolClass:
          case dateClass:
            return new ctor(+value);

          case numberClass:
          case stringClass:
            return new ctor(value);

          case regexpClass:
            result = ctor(value.source, reFlags.exec(value));
            result.lastIndex = value.lastIndex;
            return result;
        }
      } else {
        return value;
      }
      var isArr = isArray(value);
      if (isDeep) {
        // check for circular references and return corresponding clone
        stackA || (stackA = []);
        stackB || (stackB = []);

        var length = stackA.length;
        while (length--) {
          if (stackA[length] == value) {
            return stackB[length];
          }
        }
        result = isArr ? ctor(value.length) : {};
      }
      else {
        result = isArr ? slice(value) : assign({}, value);
      }
      // add array properties assigned by `RegExp#exec`
      if (isArr) {
        if (hasOwnProperty.call(value, 'index')) {
          result.index = value.index;
        }
        if (hasOwnProperty.call(value, 'input')) {
          result.input = value.input;
        }
      }
      // exit for shallow clone
      if (!isDeep) {
        return result;
      }
      // add the source value to the stack of traversed objects
      // and associate it with its clone
      stackA.push(value);
      stackB.push(result);

      // recursively populate clone (susceptible to call stack limits)
      (isArr ? arrayEach : baseForOwn)(value, function(valValue, key) {
        result[key] = baseClone(valValue, isDeep, callback, stackA, stackB);
      });

      return result;
    }
function baseClone ( value , isDeep , callback , stackA , stackB ) { if ( callback ) { var result = callback ( value ) ; if ( typeof result != 'undefined' ) { return result ; } } var isObj = isObject ( value ) ; if ( isObj ) { var className = toString . call ( value ) ; if ( ! cloneableClasses [ className ] ) { return value ; } var ctor = ctorByClass [ className ] ; switch ( className ) { case boolClass : case dateClass : return new ctor ( + value ) ; case numberClass : case stringClass : return new ctor ( value ) ; case regexpClass : result = ctor ( value . source , reFlags . exec ( value ) ) ; result . lastIndex = value . lastIndex ; return result ; } } else { return value ; } var isArr = isArray ( value ) ; if ( isDeep ) { // check for circular references and return corresponding clone stackA || ( stackA = [ ] ) ; stackB || ( stackB = [ ] ) ; var length = stackA . length ; while ( length -- ) { if ( stackA [ length ] == value ) { return stackB [ length ] ; } } result = isArr ? ctor ( value . length ) : { } ; } else { result = isArr ? slice ( value ) : assign ( { } , value ) ; } // add array properties assigned by `RegExp#exec` if ( isArr ) { if ( hasOwnProperty . call ( value , 'index' ) ) { result . index = value . index ; } if ( hasOwnProperty . call ( value , 'input' ) ) { result . input = value . input ; } } // exit for shallow clone if ( ! isDeep ) { return result ; } // add the source value to the stack of traversed objects // and associate it with its clone stackA . push ( value ) ; stackB . push ( result ) ; // recursively populate clone (susceptible to call stack limits) ( isArr ? arrayEach : baseForOwn ) ( value , function ( valValue , key ) { result [ key ] = baseClone ( valValue , isDeep , callback , stackA , stackB ) ; } ) ; return result ; }
The base implementation of `_.clone` without argument juggling or support
for `this` binding.

@private
@param {*} value The value to clone.
@param {boolean} [isDeep=false] Specify a deep clone.
@param {Function} [callback] The function to customize cloning values.
@param {Array} [stackA=[]] Tracks traversed source objects.
@param {Array} [stackB=[]] Associates clones with source counterparts.
@returns {*} Returns the cloned value.
The base implementation of _ . clone without argument juggling or support for this binding .