- //深拷贝
- export function deepClone(source) {
- if (source === null || typeof source !== 'object') {
- return source
- }
-
- const target = Array.isArray(source) ? [] : {}
- for (const key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = deepClone(source[key])
- }
- }
- return target
- }
|