The following example is working:
const data1 = {
first: 1,
second: 2
};
const data2 = {
first: 'first',
second: 'second'
};
function test(obj) {
console.log(obj.first, obj.second);
}
test(data1); // 1 2
test(data2); // first second
What do I have to do when I have data1 and data2 as nested objects in another object?
const data = {
data1: {
first: 1,
second: 2
},
data2: {
first: 'first',
second: 'second'
}
}