title: JavaScript对象过滤掉部分属性
tags:

  • JavaScript
    categories:
  • 前端
    date: 2019-06-20

示例

  1. let device = {
  2. name: '设备1',
  3. code: '867725031691391',
  4. date: '1525835791000'
  5. }
  6. const obj = (({name, date}) => ({name, date}))(device)
  7. console.log(obj) // { name: '设备1', date: '1525835791000' }
  8. let { code, ...obj } = device
  9. console.log(obj) // { name: '设备1', date: '1525835791000' }