lets say I have an object that looks like this.
{
source : 1,
target : 0
}
The object is generated on the fly as part of some data that drives a d3.js visualisation. The object indicates the link between 2 data sets in another object.
I have a filter in my visualisation that shows the data as if it were coming from a different source, so basically the link data needs to invert. Sources become targets and targets become sources so it would need to look like this,
{
source : 0,
target : 1
}
Is there a better way of doing then looping through my object and on each interation getting the source and target storing them in variables and then reassigning them?