title: JavaScript对象过滤掉部分属性
tags:
- JavaScript
categories: - 前端
date: 2019-06-20
示例
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' }