clone.js 290 B

12345678910
  1. import isObject from './isObject.js';
  2. import isArray from './isArray.js';
  3. import extend from './extend.js';
  4. // Create a (shallow-cloned) duplicate of an object.
  5. export default function clone(obj) {
  6. if (!isObject(obj)) return obj;
  7. return isArray(obj) ? obj.slice() : extend({}, obj);
  8. }