Seems like this should do the trick:

var objectA = {
    propertyA: 1,
    propertyB: 2,
    .
    . // more properties here
    .
    propertyM: 13
};

var objectB = {
    propertyN: 14,
    propertyO: 15,
    .
    . // more properties here
    .
    propertyZ: 26
};

var objectC = {...objectA, ...objectB}; // this is the answer

var a = objectC.propertyA;

var n = objectC.propertyN;

Based on this article: https://blog.mariusschulz.com/2016/12/23/typescript-2-1-object-rest-and-spread


In addition, the order of the variables in the decomposition matters. Consider the following:

var objectA = {
    propertyA: 1,
    propertyB: 2, // same property exists in objectB
    propertyC: 3
};

var objectB = {
    propertyX: 'a',
    propertyB: 'b', // same property exists in objectA
    propertyZ: 'c'
};

// objectB will override existing properties, with the same name,
// from the decomposition of objectA
var objectC = {...objectA, ...objectB}; 

// result: 'b'
console.log(objectC.propertyB); 

// objectA will override existing properties, with the same name,
// from the decomposition of objectB
var objectD = {...objectB, ...objectA}; 

// result: '2'
console.log(objectD.propertyB); 
Answer from alkasai on Stack Overflow
๐ŸŒ
Omarileon
omarileon.me โ€บ blog โ€บ typescript-merge-objects
mari. | 3 Simple Ways to Merge Objects in TypeScript
January 26, 2024 - The easiest solution to merge objects in TypeScript or JavaScript is the spread syntax, or spread operator.
Discussions

How can I merge properties of two JavaScript objects? - Stack Overflow
ES2018/TypeScript: Many answers are OK but I've come up with a more elegant solution to this problem when you need to merge two objects without overwriting overlapping object keys. More on stackoverflow.com
๐ŸŒ stackoverflow.com
[HELP] How to join two objects of different types on matching keys?
It sounds like what you're trying to do is strip offโ€”at runtimeโ€”any properties from objB that don't exist in TypeA. Fundamentally, you're going to need to write something to do the comparison and remove any unwanted fields. The reason is that types in TypeScript exist only at compile time, they are completely removed from the final JS output. So at runtime, there isn't any concept of TypeA any more, the objects are just JS objects. In order to do a runtime check, you'll need to encode the fields in some way that exists at runtime, then write a comparison that references that list of fields. More on reddit.com
๐ŸŒ r/typescript
6
3
May 4, 2021
Two objects with different attributes into one

Simply just push the object into the array using push:

i.e:

let arrObj = [{firstname: "John", lastname: "Doe"}, {firstname: "Steve", lastname: "Doe"}];
let objToAdd = {firstname: "Carlos", lastname: "Doe", email: "carlosdoe@example.com"}; 
arrObj.push(objToAdd);
More on reddit.com
๐ŸŒ r/typescript
1
1
November 18, 2021
How to sum multiple object with the same key in an array?
https://jsfiddle.net/dwo0dy7y/ It's not pretty, you could probably use Array.reduce to create something a bit prettier but I'm going to assume you're not familiar with all the Array methods and stick to basics. If you're feeling adventurous: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce?v=control More on reddit.com
๐ŸŒ r/learnjavascript
9
2
May 10, 2017
๐ŸŒ
Aaron Bos
aaronbos.dev โ€บ posts โ€บ merge-objects-typescript-javascript
Merging Objects in TypeScript (and JavaScript)
June 11, 2022 - The reason for this being is that shallow merging pertains to simply copying property values from one or many objects to another. If a property is a reference type like an object or array, then the reference will be copied instead of creating entirely new objects. The two most common methods of shallow merging in TS and JS are Object.assign() and using the ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ typescript โ€บ how-to-deep-merge-two-objects-in-typescript
How to Deep Merge Two Objects in TypeScript ? - GeeksforGeeks
June 16, 2025 - In this article, we will explore various approaches to deep merging objects in TypeScript, along with their syntax and examples. ... This approach involves recursively traversing the objects and merging their properties.
๐ŸŒ
Tim Mousk
timmousk.com โ€บ blog โ€บ typescript-merge-objects
How To Merge Objects In TypeScript? โ€“ Tim Mouskhelichvili
March 27, 2023 - The easiest solution to merge objects in TypeScript involves using the spread operator.
๐ŸŒ
Medium
medium.com โ€บ @glasshost โ€บ how-to-merge-objects-in-typescript-52e2d64e77b6
How to merge Objects in TypeScript | by Glasshost | Medium
April 14, 2023 - const obj1 = { a: 1, b: 2 }; const obj2 = { b: 3, c: 4 }; const mergedObj = Object.assign(obj1, obj2); console.log(mergedObj); // Output: { a: 1, b: 3, c: 4 } In the example above, we merged `obj2` into `obj1` using `Object.assign()`. Note that the `Object.assign()` method mutates the target object (`obj1`), so we need to make a copy of the source object if we want to keep the original object.
๐ŸŒ
TypeScript
typescriptlang.org โ€บ docs โ€บ handbook โ€บ declaration-merging.html
TypeScript: Documentation - Declaration Merging
Currently, classes can not merge with other classes or with variables. For information on mimicking class merging, see the Mixins in TypeScript section. Although JavaScript modules do not support merging, you can patch existing objects by importing and then updating them.
Find elsewhere
๐ŸŒ
SPGuides
spguides.com โ€บ merge-two-objects-in-typescript
How to Merge Two Objects in TypeScript?
February 7, 2024 - In TypeScript, you can merge two objects by using the spread operator โ€ฆ to combine the properties of both objects into a new one. Alternatively, you can use Object.assign() to achieve the same result.
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ typescript-merge-objects
How to merge Objects in TypeScript | bobbyhadz
Use the spread syntax (...) to merge objects in TypeScript. The type of the final object will successfully be inferred.
๐ŸŒ
Squash
squash.io โ€บ tutorial-on-merging-objects-in-typescript
How to Merge Objects in TypeScript - Squash Labs
May 8, 2024 - TypeScript provides several techniques for merging objects, including merging two objects, merging properties of objects, object spreading, using Object.assign, merging objects with same keys, merging objects with different keys, and merging nested objects.
๐ŸŒ
DEV Community
dev.to โ€บ fullstackchris โ€บ advanced-typescript-a-generic-function-to-merge-object-arrays-18ja
Advanced TypeScript: A Generic Function to Merge Object Arrays - DEV Community
December 9, 2021 - Therefore, we need to ensure we are merging the proper object on some sort of matchKey, which will have to be keyof T, since some keys in U may not exist in T. With matchKey defined, we should only need the other two arrays, the existing and incoming array, to define this function's signature:
๐ŸŒ
Sling Academy
slingacademy.com โ€บ home โ€บ typescript โ€บ how to merge multiple objects in typescript (2 approaches)
How to Merge Multiple Objects in TypeScript (2 Approaches) - Sling Academy
December 3, 2023 - const objectOne = { name: 'Product One', price: 100, description: 'This is product one', }; const objectTwo = { weight: 100, color: 'red', }; const objectThree = { name: 'Product Three', descriptioN: 'Some text', color: 'blue', }; // Merge objectOne and objectTwo by using Object.assign() const resultOne = Object.assign({}, objectOne, objectTwo); console.log(resultOne); // Merge objectOne, objectTwo, and objectThree by using Object.assign() const resultTwo = Object.assign({}, objectOne, objectTwo, objectThree); console.log(resultTwo); ... // console.log(resultOne); { name: 'Product One', price:
๐ŸŒ
xjavascript
xjavascript.com โ€บ blog โ€บ typescript-merge-two-objects
Merging Two Objects in TypeScript: A Comprehensive Guide โ€” xjavascript.com
The spread operator and Object.assign() are simple and efficient for basic merging, while custom functions give more control over the process. When dealing with nested objects, a deep merge function is required.
๐ŸŒ
Decipher
decipher.dev โ€บ merge
merge | 30 Seconds of Typescript
const object = { a: [{ x: 2 }, { y: 4 }], b: 1, }; const other = { a: { z: 3 }, b: [2, 3], c: "foo", }; merge(object, other); // { a: [ { x: 2 }, { y: 4 }, { z: 3 } ], b: [ 1, 2, 3 ], c: 'foo' }
๐ŸŒ
Webdevtutor
webdevtutor.net โ€บ blog โ€บ typescript-how-to-merge-two-objects
TypeScript: How to Merge Two Objects
One of the simplest ways to merge two objects in TypeScript is by using the spread operator.
๐ŸŒ
DEV Community
dev.to โ€บ svehla โ€บ typescript-how-to-deep-merge-170c
How to deep merge in Typescript - DEV Community
October 5, 2021 - If itโ€™s true it merges them via MergeTwoObject<>. This process is recursively repeated for all nested objects.
๐ŸŒ
DEV Community
dev.to โ€บ techsquidtv โ€บ combine-objects-in-typescript-3f64
Combine Objects In TypeScript - DEV Community
April 11, 2021 - In this example, we will be creating Super Heros by combining our regular Heros with SuperPowers to result in a single Super Hero. Begin by creating an Interface for each of the two objects.
๐ŸŒ
SPGuides
spguides.com โ€บ typescript-array-concatenation
TypeScript Merge Arrays | TypeScript Merge Two Arrays Of Objects
June 29, 2025 - To merge two arrays of objects in TypeScript, you can use the spread operator (...) for a simple concatenation. If you need to ensure uniqueness based on a specific property, use a Map to filter out duplicates.
๐ŸŒ
YouTube
youtube.com โ€บ watch
Merge with Mike Poteat - TypeScript Type Challenges #599 ...
To learn more, please visit the YouTube Help Center: https://www.youtube.com/help