Skip to content

深拷贝 ​

2023-03-06 10:36:36

ts
function deepClone(source) {
  const target = {}
  for (property in source) {
    if (typeof source[property] === 'object') {
      target[property] = deepClone(source[property])
    } else {
      target[property] = source[property]
    }
  }
  return target
}

Released under the MIT License.