I would like to specify one of the keys for options
to be a value from my constants
object but cannot use dot notation inside object declaration.
Is there a shorthand way of doing this without declaring an additional variable before options
only to hold the value?
Error:
SyntaxError: missing : after property id
Code:
var constants = {
KEY: 'Content-Type'
}
var options = {
constants.KEY: 'application/json'
};
alert(options);