当前位置:网站首页>es6删除对象的某个属性
es6删除对象的某个属性
2022-06-13 07:52:00 【西洲 -】
1.不改变原始对象
方法1(删除age属性为例)
const obj = {
name: 'xingxing',
gender: 'girl',
age: 24
};
const objNew = (({
name,
gender
}) => ({
name,
gender
}))(obj)
console.log(obj)
console.log(objNew)
输出如下:

方法2(删除age为例)
const obj = {
name: 'xingxing',
gender: 'girl',
age: 24
};
let {age,...objNew} = obj
console.log(objNew)
console.log(obj)
2 delete删除,改变原有数组
删除age属性为例
let obj = {
name: 'xingxing',
gender: 'girl',
age: 24
};
delete obj.age
console.log(obj)边栏推荐
- 26 | Superscalar和VLIW:如何让CPU的吞吐率超过1
- Simple use of logs
- 25 domestic and foreign literature databases
- [log4j2 log framework] modify dump log file permissions
- Logback log framework learning and problems
- MySQL: regexp_ replace
- Redis underlying data structure - underlying principle of hash table
- Login registration
- 【PYTORCH】Expected object of type torch. xxxTensor but found type torch. cuda. xxxTensor(torch0.4.0)
- Precautions for passing parameters with byte array
猜你喜欢

Compare advantages and disadvantages of DFS and BFS and name vocabulary
![[redis problem] record a big key problem handling](/img/ad/787d5911fac2cc2105e439d906b67f.jpg)
[redis problem] record a big key problem handling

v-for生成的子组件列表删除第n行出现数据错乱问题

21 | pipeline oriented instruction design (Part 2): How did Pentium 4 fail?

MySQL Gtid_ Executed and gtid_ Purged modification time

11.29 Li Kou swipes questions every day

22 | adventure and prediction (I): hazard is both "danger" and "opportunity"

Web site access excel in IIS

First graphical interface

22 | 冒险和预测(一):hazard是“危”也是“机”
随机推荐
[log framework] add user-defined parameters to the MDC implementation log
Redis learning journey -- subscription and publishing
24 | 冒险和预测(三):CPU里的“线程池”
Coalesce() function
First graphical interface (modified version)
MySQL table partitioning
Redis Cluster - the underlying principle of slot assignment
【深度学习】:《PyTorch入门到项目实战》(十二)卷积神经网络:填充(padding)和步幅(stride)
China phosphate market in-depth analysis and investment prospect forecast report 2022-2028
Redis master-slave replication - underlying principle
21 | pipeline oriented instruction design (Part 2): How did Pentium 4 fail?
Redis Cluster - the bottom principle of building clusters
23 | 冒险和预测(二):流水线里的接力赛
安装CUDA+CUSP环境,并创建第一个HelloWord入门工程
MySQL row column conversion (updated version)
Redis master-slave replication - the underlying principle of partial resynchronization
Pdf to word
【PYTORCH】RuntimeError: one of the variables needed for gradient computation has been
Index invalidation caused by inaccurate MySQL statistics
Free file server storage technology
