当前位置:网站首页>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 }
边栏推荐
- Implementation of map and set
- 预处理——插值
- Simple implementation of AVL tree insertion and verification operations
- 1.19.11.SQL客户端、启动SQL客户端、执行SQL查询、环境配置文件、重启策略、自定义函数(User-defined Functions)、构造函数参数
- OSCP工具之一: dirsearch用法大全
- idea gradle lombok 报错集锦
- 太方便了,钉钉上就可完成代码发布审批啦!
- SQL injection -day15
- 2022电工杯A题高比例风电电力系统储能运行及配置分析思路
- Class常量池与运行时常量池
猜你喜欢
自适应非欧表征广告检索系统AMCAD
Class constant pool and runtime constant pool
Some thoughts on cross end development of kbone and applet
On file uploading of network security
codeforces每日5题(均1700)-第七天
卡尔曼滤波-1
Top 50 hit industry in the first half of 2022
[security attack and Defense] how much do you know about serialization and deserialization?
[development software] tilipa Developer Software
QT 打开文件 使用 QFileDialog 获取文件名称、内容等
随机推荐
PHP 实现根据概率抽奖
【开发软件】 tilipa开发者软件
Codeworks 5 questions per day (1700 average) - day 7
Index of MySQL
使用 Dumpling 备份 TiDB 集群数据到 GCS
HW notes (II)
Preprocessing - interpolation
【安全攻防】序列化与反序列,你了解多少?
SSL certificate deployment
AVL树插入操作与验证操作的简单实现
复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
三重半圆环进度条,直接拿去就能用
Kotlin Android environment construction
如何编写一个程序猿另一个面试官眼前一亮的简历[通俗易懂]
Collection of idea gradle Lombok errors
使用Thread类和Runnable接口实现多线程的区别
2022年电工杯B 题 5G 网络环境下应急物资配送问题思路分析
opencv第三方库
二叉搜索树的实现
浅谈网络安全之文件上传