JavaScript对象过滤掉部分属性

示例

1
2
3
4
5
6
7
8
9
10
11
let device = {
name: '设备1',
code: '867725031691391',
date: '1525835791000'
}

const obj = (({name, date}) => ({name, date}))(device)
console.log(obj) // { name: '设备1', date: '1525835791000' }

let { code, ...obj } = device
console.log(obj) // { name: '设备1', date: '1525835791000' }

推荐文章