当前位置:网站首页>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 }
边栏推荐
- 再AD 的 界面顶部(菜单栏)创建常用的快捷图标
- UltraEdit-32 温馨提示:右协会,取消 bak文件[通俗易懂]
- 1.19.11.SQL客户端、启动SQL客户端、执行SQL查询、环境配置文件、重启策略、自定义函数(User-defined Functions)、构造函数参数
- ABAP dynamic inner table grouping cycle
- [leetcode] 450 and 98 (deletion and verification of binary search tree)
- Summer 2022 daily question 1 (1)
- Hisilicon 3559 universal platform construction: RTSP real-time playback support
- 什么是 BA ?BA怎么样?BA和BI是什么关系?
- On file uploading of network security
- Collection of idea gradle Lombok errors
猜你喜欢
[leetcode] 700 and 701 (search and insert of binary search tree)
QT thread and other 01 concepts
一些常用软件相关
浅谈网络安全之文件上传
Hisilicon 3559 universal platform construction: RTSP real-time playback support
QT opens a file and uses QFileDialog to obtain the file name, content, etc
What is Ba? How about Ba? What is the relationship between Ba and Bi?
VHDL implementation of single cycle CPU design
【开发软件】 tilipa开发者软件
史上最全MongoDB之安全认证
随机推荐
如何编写一个程序猿另一个面试官眼前一亮的简历[通俗易懂]
vim —- 自己主动的按钮indent该命令「建议收藏」
未来发展路线确认!数字经济、数字化转型、数据...这次会议很重要
Index of MySQL
卡尔曼滤波-1
维护万星开源向量数据库是什么体验
ABAP 动态内表分组循环
HW notes (II)
Create commonly used shortcut icons at the top of the ad interface (menu bar)
Some thoughts on cross end development of kbone and applet
Kotlin Android environment construction
Delete data in SQL
Class常量池与运行时常量池
二叉搜索树的实现
Redis源码学习(30),字典学习,dict.h
Storage of data
tflite模型转换和量化
UltraEdit-32 温馨提示:右协会,取消 bak文件[通俗易懂]
What is Ba? How about Ba? What is the relationship between Ba and Bi?
codeforces每日5题(均1700)-第七天