filmov
tv
How to use a variable for a key in a JavaScript object literal?

Показать описание
#short
#javascript
#variables
#properties
#object-literal
Why does the following work?
{ 'top' : 10 }, 10
);
Whereas this doesn't work:
var thetop = 'top';
{ thetop : 10 }, 10
);
To make it even clearer: At the moment I'm not able to pass a CSS property to the animate function as a variable.
#javascript
#variables
#properties
#object-literal
Why does the following work?
{ 'top' : 10 }, 10
);
Whereas this doesn't work:
var thetop = 'top';
{ thetop : 10 }, 10
);
To make it even clearer: At the moment I'm not able to pass a CSS property to the animate function as a variable.