I am using Vue.js and I have 2 objects that I would like to combine together but to keep them separated.
I tried to use a spread such as var obj1 = {...obj2, ...obj3} but realized that this was overwriting values because names were the same. I changed the billing address information to have "billing" in front of them and using that same process again, its just a very long list and not very clean to me.
Below are the 2 objects that I am trying to combine.
deliveryAddress: {
firstName: null,
lastName: null,
companyName: null,
jobTitle: null,
address1: null,
address2: null,
city: null,
country: null,
province: null,
region: null,
state: null,
zipCode: null,
phoneNumber: null,
email: null
},
billingAddress: {
billingDifferentFromDelivery: false,
billingAddress1: null,
billingAddress2: null,
billingCity: null,
billingCountry: null,
billingState: null,
billingProvince: null,
billingZipCode: null,
}
I would like to combine these as either an object with both objects or as an array with both objects. Maybe something similar to this
var addressInformation = {
deliveryAddress: {
firstName: null,
lastName: null,
companyName: null,
jobTitle: null,
address1: null,
address2: null,
city: null,
country: null,
province: null,
region: null,
state: null,
zipCode: null,
phoneNumber: null,
email: null
},
billingAddress: {
billingDifferentFromDelivery: false,
billingAddress1: null,
billingAddress2: null,
billingCity: null,
billingCountry: null,
billingState: null,
billingProvince: null,
billingZipCode: null,
}
}
or
var addressInformation = [{
deliveryAddress: {
firstName: null,
lastName: null,
companyName: null,
jobTitle: null,
address1: null,
address2: null,
city: null,
country: null,
province: null,
region: null,
state: null,
zipCode: null,
phoneNumber: null,
email: null
},
billingAddress: {
billingDifferentFromDelivery: false,
billingAddress1: null,
billingAddress2: null,
billingCity: null,
billingCountry: null,
billingState: null,
billingProvince: null,
billingZipCode: null,
}
}]
is this possible? is there a better way to clean this up when combining objects?