当前位置:网站首页>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 }
边栏推荐
- 如何检测mysql代码运行是否出现死锁+binlog查看
- Some common software related
- Ggplot facet detail adjustment summary
- What is the experience of maintaining Wanxing open source vector database
- How to detect whether the MySQL code runs deadlock +binlog view
- Native MySQL
- 使用Thread类和Runnable接口实现多线程的区别
- idea gradle lombok 报错集锦
- 【安全攻防】序列化与反序列,你了解多少?
- OSCP工具之一: dirsearch用法大全
猜你喜欢
![[dpdk] dpdk sample source code analysis III: dpdk-l3fwd_ 001](/img/f6/dced69ea36fc95ef84bb546c56dd91.png)
[dpdk] dpdk sample source code analysis III: dpdk-l3fwd_ 001

Calculation of time and space complexity (notes of runners)

ABAP 動態內錶分組循環

机器学习笔记 - 使用机器学习进行鸟类物种分类
Docker部署Mysql8的实现步骤

机械臂速成小指南(十):可达工作空间

Class constant pool and runtime constant pool

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

【安全攻防】序列化與反序列,你了解多少?

Implementation of map and set
随机推荐
ERROR: Could not build wheels for pycocotools which use PEP 517 and cannot be installed directly
tflite模型转换和量化
二叉搜索树的实现
2022夏每日一题(一)
PHP lightweight Movie Video Search Player source code
MySQL的索引
The JSON format of the international area code of the mobile phone number is obtained with PHP
2022中青杯C题城市交通思路分析
1.19.11.SQL客户端、启动SQL客户端、执行SQL查询、环境配置文件、重启策略、自定义函数(User-defined Functions)、构造函数参数
红米k40s root玩机笔记
How to detect whether the MySQL code runs deadlock +binlog view
Construction of Hisilicon universal platform: color space conversion YUV2RGB
复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
The true face of function pointer in single chip microcomputer and the operation of callback function
Mysql-数据丢失,分析binlog日志文件
opencv第三方库
如何编写一个程序猿另一个面试官眼前一亮的简历[通俗易懂]
预处理——插值
C task expansion method
太方便了,钉钉上就可完成代码发布审批啦!