当前位置:网站首页>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 }
边栏推荐
- Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
- cuda编程
- 二叉搜索树的实现
- MySQL的索引
- Allow public connections to local Ruby on Rails Development Server
- 海思万能平台搭建:颜色空间转换YUV2RGB
- Force buckle ----- path sum III
- easyui出口excel无法下载框弹出的办法来解决
- [leetcode]Spiral Matrix II
- Unity3D在一建筑GL材料可以改变颜色和显示样本
猜你喜欢

NoSQL之Redis配置与优化

Confirm the future development route! Digital economy, digital transformation, data This meeting is very important

On file uploading of network security

史上最全学习率调整策略lr_scheduler

【mysql】mysql中行排序

机器学习笔记 - 使用机器学习进行鸟类物种分类

【开发软件】 tilipa开发者软件

My brave way to line -- elaborate on what happens when the browser enters the URL

概率论公式

QT 项目 表格新建列名称设置 需求练习(找数组消失的数字、最大值)
随机推荐
opencv第三方库
接口数据安全保证的10种方式
复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
Implementation of binary search tree
QT 使用QToolTip 鼠标放上去显示文字时会把按钮的图片也显示了、修改提示文字样式
QT 打开文件 使用 QFileDialog 获取文件名称、内容等
2022夏每日一题(一)
一些常用软件相关
Vernacular high concurrency (2)
QT 项目 表格新建列名称设置 需求练习(找数组消失的数字、最大值)
Kotlin Android 环境搭建
数据的存储
On file uploading of network security
运算放大器应用汇总1
API data interface of A-share index component data
ABAP 動態內錶分組循環
codeforces每日5题(均1700)-第七天
tflite模型转换和量化
Create commonly used shortcut icons at the top of the ad interface (menu bar)
链表面试常见题