当前位置:网站首页>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)边栏推荐
- Selenium foundation API
- 【Emgu.CV】Emgu. CV. Example\ocr operation reports an error system IO. Filenotfoundexception: "failed to load file or assembly" system.drawing.common "
- 8. process status and transition
- 【Emgu.CV】Emgu.CV.Example\OCR运行报错System.IO.FileNotFoundException:“未能加载文件或程序集“System.Drawing.Common
- Simple use of logs
- Considerations for using redis transactions
- Redis learning journey --redis Conf details
- Install cuda+cusp environment and create the first helloword starter project
- Go 接口实现原理【高阶篇】: type _interface struct
- Index invalidation caused by inaccurate MySQL statistics
猜你喜欢

Redis learning journey sentinel mode

Redis Cluster - the underlying principle of cluster execution commands

Precautions for passing parameters with byte array

Redis learning journey --redis Conf details
![[log framework] add user-defined parameters to the MDC implementation log](/img/94/5c0c51663f6a26d2ccf4a81047060f.jpg)
[log framework] add user-defined parameters to the MDC implementation log

Paper notes: multi label learning bp-mll

Advanced MySQL: how to learn MySQL source code
![[deep learning]: introduction to pytorch to project practice (XII) convolutional neural network: padding and stride](/img/19/18d6e94a1e0fa4a75b66cf8cd99595.png)
[deep learning]: introduction to pytorch to project practice (XII) convolutional neural network: padding and stride

21 | 面向流水线的指令设计(下):奔腾4是怎么失败的?

【clickhouse专栏】基础数据类型说明
随机推荐
Redis master-slave replication - the underlying principle of partial resynchronization
Remote office solution under epidemic situation
Three handshakes and four waves of TCP protocol and why------ One two pandas
Go interface implementation principle [advanced level]: type_ interface struct
Selenium reports an error deprecationwarning: executable_ path has been deprecated, please pass in a Service object
思路清晰的软光栅小引擎和四元数结合案例
Redis learning journey sentinel mode
力扣(LeetCode)163. 缺失的区间(2022.06.12)
2022 electrician (elementary) examination questions and simulation examination
安装CUDA+CUSP环境,并创建第一个HelloWord入门工程
【clickhouse专栏】基础数据类型说明
Redis Cluster - the bottom principle of building clusters
Coalesce() function
Redis underlying data structure - underlying principle of hash table
Some optimization for seckill project
[Yu Yue education] econometrics reference materials of Jiujiang University
Paper notes: multi label learning bp-mll
[tools for quickly creating MySQL stand-alone and cluster test environments] dbdeployer
【Emgu.CV】Emgu. CV. Example\ocr operation reports an error system IO. Filenotfoundexception: "failed to load file or assembly" system.drawing.common "
Learning notes of balanced binary tree -- one two pandas
