Object的rest和spread方法

时间:2020-01-23 23:42:45   收藏:0   阅读:136
//将多个对象合并到一个对象里
const input = {
  a: 1,
  b: 2
}
const test = {
  d: 5
}
const output = {
  ...input,
  ...test,
  c: 3
}

//拆解对象,获取想要的属性
const input = {
  a: 1,
  b: 2,
  c: 3,
  d: 4,
  e: 5
}
const { a, b, ...rest } = input
console.log(a,b,rest)

 

原文:https://www.cnblogs.com/qjb2404/p/12231668.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!