I have the following forEach loop to iterate over stored jQuery selectors:
contentExtras = [
{ right: $right_mask, start: aVariable, end: 0 },
{ right: $le, start: 0, end: bVariable },
{ left: $left_mask, start: cVariable, end: 0 }
];
Now I can do:
contentExtras.forEach( function( item ) {
item.right.css( { top: item.start } );
} );
or:
contentExtras.forEach( function( item ) {
item.left.css( { bottom: item.start } );
} );
Now I am looking for a way to do get the value of every first key/value pair independent of wether it is "right" or "left".
In the way that I could do something like:
contentExtras.forEach( function( item ) {
item.["both left and right"].css( { bottom: item.start } );
} );
I tried things like: item.[0] but without success. Does this explain sufficiently what I need? Thanks in advance for help!
EDIT:
So this is the part of the answer of Rayon that solved my problem:
contentExtras.forEach( function( item ) {
item[Object.keys(item)[0]].doThingsWithItsValues()
} );