js用户自定义配置替换默认配置方法

const customConfig = { a: 22, b: 33 }

function config(config = {}) {
  const defaultConfig = { a: 12, b: 23, c: 'aa' }
  const finallyConfig = { ...defaultConfig, ...customConfig }
  console.log(finallyConfig)//{ a: 22, b: 33, c: 'aa' }
}
config(customConfig)

 

posted @ 2024-07-18 18:02  howhy  阅读(2)  评论(0编辑  收藏  举报