When JQ defines css, can the key name use a variable?

if...{
    a="left";
}else{
    a="right";
}

obj.css({
    a:"20px"
})

as above, the above practice does not work, is there any way to make this an a variable?
because of the complexity of the situation, you have to do this, which can save you a lot of trouble. Does anyone know this can be achieved?

Mar.21,2022

you can write this directly in high-version browsers

obj.css({
  [a]: '20px',
});

if you are writing a production page directly for compatibility, you should write

like this.
var style = {};
style[a] = '20px';
obj.css(style);
Menu