当前位置:网站首页>Learn how to use js to merge two objects into one object assign()
Learn how to use js to merge two objects into one object assign()
2022-07-07 04:02:00 【Lingering memory of Yu Fei】
Learn to use js Method of merging two objects into one object Object.assign
Object.assign() Method
Object.assign() Method to copy the values of all enumerable properties from one or more source objects to the target object . It will return the target object
Merge objects
var o1 = {
a: 1 };
var o2 = {
b: 2 };
var o3 = {
c: 3 };
var obj = Object.assign(o1, o2, o3);
console.log(obj); // { a: 1, b: 2, c: 3 }
console.log(o1); // { a: 1, b: 2, c: 3 }, Notice that the target object itself changes
Merge objects with the same properties
var o1 = {
a: 1, b: 1, c: 1 };
var o2 = {
b: 2, c: 2 };
var o3 = {
c: 3 };
var obj = Object.assign({
}, o1, o2, o3);
console.log(obj); // { a: 1, b: 2, c: 3 }
边栏推荐
- My brave way to line -- elaborate on what happens when the browser enters the URL
- MySQL的索引
- ggplot 分面的细节调整汇总
- Binary, octal, hexadecimal
- A 股指数成分数据 API 数据接口
- What is the experience of maintaining Wanxing open source vector database
- Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation
- [security attack and Defense] how much do you know about serialization and deserialization?
- codeforces每日5题(均1700)-第七天
- 数据的存储
猜你喜欢

leetcode:面试题 17.24. 子矩阵最大累加和(待研究)

On file uploading of network security

It's too convenient. You can complete the code release and approval by nailing it!

Create commonly used shortcut icons at the top of the ad interface (menu bar)

2022中青杯C题城市交通思路分析

一些常用软件相关

Kbone与小程序跨端开发的一些思考

Storage of data

Hisilicon 3559 universal platform construction: RTSP real-time playback support

tflite模型转换和量化
随机推荐
Allow public connections to local Ruby on Rails Development Server
map和set的实现
[development software] tilipa Developer Software
Tencent cloud native database tdsql-c was selected into the cloud native product catalog of the Academy of communications and communications
QT 打开文件 使用 QFileDialog 获取文件名称、内容等
【安全攻防】序列化与反序列,你了解多少?
Antd Comment 递归循环评论
Kotlin Android environment construction
Probability formula
Index of MySQL
10 ways of interface data security assurance
What is Ba? How about Ba? What is the relationship between Ba and Bi?
一些常用软件相关
运算放大器应用汇总1
ABAP Dynamic Inner table Group cycle
Arduino droplet detection
Hisilicon 3559 universal platform construction: RTSP real-time playback support
史上最全学习率调整策略lr_scheduler
再AD 的 界面顶部(菜单栏)创建常用的快捷图标
C task expansion method